Home/Tutorials/JavaScript/Promises and Async/Await

0 of 3 saved

JavaScript5 min read

Promises and Async/Await

Read this chapter, write the program on this page, then pass a short check to open the next one.

Async without callback pyramids.

Promises and Async/Await

A Promise represents a future value. async/await lets you write async code that reads like sync code.

  • await pauses an async function until the Promise settles.
  • Always handle rejection with try/catch or .catch.
  • Promise.all runs independent work in parallel.
async function main() {
  const value = await Promise.resolve("ready");
  console.log(value);
}
main();

After you read this chapter, use Write (when available) and Quiz on this page to lock it in.