Async

A function always returns a promise.

Function returns a promise, and wraps non-promises in it.

Syntax

Async function f() {
  return 1;
}

Await

Makes JavaScript wait until that promise settles and returns its result.

The await keyword before a promise makes JavaScript wait until that promise settles, and then.

Syntax

// works only inside async functions
let value = await promise;
If it's an error, the exception is generated, same as if throw error were called at that very place.
Otherwise, it returns the result, so we can assign it to a value.

Related concepts

Async — Structure map

Clickable & Draggable!

Async — Related pages: