Example 1 — Parallel with Promise.all
Don't await in a slow chain when independent.
JavaScript
(async () => {
const [a, b] = await Promise.all([
Promise.resolve(1),
Promise.resolve(2),
]);
console.log(a + b);
})();How It Works
- Both start together.
- Await the combined promise.
