bhylu.com

Advertisements

Async Parallel

Promise.all waits for several independent operations together. Start the operations before awaiting the combined result.

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

const [places, price] = await Promise.all([
  Promise.resolve(12),
  Promise.resolve(6)
]);
console.log(places * price);

What happens

The two results combine to give 72.