bhylu.com

Advertisements

Async Programming

Async functions always return a promise. Await pauses that function until a promise settles without blocking the whole browser.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

async function loadPlaces() {
  return 12;
}
console.log(await loadPlaces());

What happens

The resolved value is 12.