JavaScript Async and Await
async
functions and await
are part of ECMAScript 2017(ES8).
These features basically act as syntactic sugar on top of promises.
They make asynchronous code look like synchronous code.
They make code much simpler and easier to understand.
async functions
async
functions returned values are guaranteed to be converted
into promises.
await keyword
await
works only inside async
functions. await
keyword put in
front of any async promise based function causes the line to pause
until the promise fulfills.
References:
Categories :
JavaScript
ES8