My Portfolio

Edit this page

Async & Await

May 22, 2020

There’s a special syntax to work with promises in a more comfortable fashion, called “async/await”. It’s surprisingly easy to understand and use

Async Functions

Async keyword can be placed before the function definition. Example:

async function f() {
  return 1;
}

The async keyword before above function is implying that the above function will always return a promise. All consumer methods of promise like ```` then() , catch() ```, etc. can be used on above function. Example:

async function f() {
  return 1;
}

f().then(alert); // 1

Work in Progress

My Portfolio

Made with love ♥ using Jekyll.