JavaScript Tutorial

The language for programming web pages.

JS Promises & Async

JavaScript Promises & Async/Await

Promises handle asynchronous operations. async/await makes asynchronous code look and behave like synchronous code.

Promise States:

  • Pending — Initial state
  • Fulfilled — Operation succeeded
  • Rejected — Operation failed

Async/Await:

The async keyword makes a function return a Promise. The await keyword waits for a Promise to resolve.

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics