await/async javascript
async/await
simply gives you a synchronous feel to asynchronous code. It's a very elegant form of syntactical sugar.
For simple queries and data manipulation, Promises can be simple, but if you run into scenarios where there's complex data manipulation and whatnot involved, it's easier to understand what's going on if the code simply looks as though it's synchronous (to put it another way, syntax in and of itself is a form of "incidental complexity" that
async/await
can get around).
If you're interested to know, you can use a library like
co
(alongside generators) to give the same sort of feel. Things like this have been developed to solve the problem that async/await
ultimately solves (natively).
Comments
Post a Comment