JavaScript Promise all() Method

Beginner
6 min read
Updated: Nov 2026
3 examples
Static method

Definition

Promise.all(promises) takes a list of promises and returns one new promise. It fulfills when every promise has fulfilled, with an array of their values in input order, no matter which finished first. If any promise rejects, the result rejects at once with that first rejection. Plain values in the list count as already fulfilled, and an empty list gives [].

Remember
Promise.all([a, b, c])   -> one promise

all fulfill  -> [valueA, valueB, valueC]  (input order)
one rejects  -> rejects with the FIRST error (fail fast)
plain value  -> treated as already fulfilled
[]           -> fulfills with []

Syntax

Call it on Promise with an array (or any iterable) of promises.

JavaScript
Promise.all(iterable)
const values = await Promise.all(iterable);
CallWhat it does
Promise.all([p1, p2])Wait for both; get [value1, value2].
Promise.all(items.map(fn))Start one task per item, then wait for all of them.

A static method, part of JavaScript since ES2015. It does not start any work; the tasks are already running when you pass their promises.

Library declarations
JavaScript
Promise.all(iterable)   // returns a Promise

// fulfills with: an array of values, same order as iterable
// rejects with:  the reason of the first promise that rejects

Parameters

ParameterDescription
iterableAn array (or other iterable) of promises. Non-promise values are wrapped with Promise.resolve(), so [1, p] works.

Return Value

Return ValueDescription
PromiseFulfills with an array of all values in input order, or rejects with the first rejection reason.

JavaScript Examples

Example 1 — Load Three Things at Once

A page often needs several pieces of data. Here setTimeout stands in for three network requests that finish at different times.

JavaScript
function wait(ms, value) {
  return new Promise((resolve) => {
    setTimeout(() => {
      console.log('finished: ' + value);
      resolve(value);
    }, ms);
  });
}

Promise.all([wait(90, 'user'), wait(30, 'posts'), wait(60, 'settings')])
  .then((values) => {
    console.log(JSON.stringify(values));
  });

console.log('waiting...');
Try It Yourself

How It Works

  1. All three timers start together. Each wait() call starts its timer immediately, so the total wait is about 90 ms, the slowest task, not 180 ms. The synchronous waiting... line prints first.
  2. They finish in their own order. posts (30 ms) finishes first, then settings, then user. Promise.all keeps waiting until the last one is done.
  3. The array keeps input order. The values come back as user, posts, settings: the order of the array you passed in, not the order the tasks finished.

Example 2 — One Failure Rejects Everything

Task B fails. Watch when catch() runs, and notice that task C still finishes afterwards.

JavaScript
function task(ms, name, fail) {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      console.log(name + ' done');
      if (fail) reject(new Error(name + ' failed'));
      else resolve(name);
    }, ms);
  });
}

Promise.all([task(30, 'A', false), task(60, 'B', true), task(120, 'C', false)])
  .then((values) => console.log('all ok: ' + values.join(', ')))
  .catch((error) => console.log('caught: ' + error.message));
Try It Yourself

How It Works

  1. A fulfills, B rejects. At 30 ms A succeeds. At 60 ms B calls reject() with its own error message.
  2. The result rejects immediately. Promise.all does not wait for C. Its promise rejects with B's error, so then is skipped and catch prints caught: B failed.
  3. C is not cancelled. C's timer still fires at 120 ms and logs C done, but its value goes nowhere. A promise cannot stop work that has already started.

Example 3 — With await, map(), and Edge Cases

The most common real pattern is await Promise.all(list.map(...)). This example also shows plain values and an empty list.

JavaScript
function getPrice(item) {
  const prices = { apple: 3, bread: 5, milk: 2 };
  return new Promise((resolve) => setTimeout(() => resolve(prices[item]), 30));
}

async function main() {
  const cart = ['apple', 'bread', 'milk'];
  const prices = await Promise.all(cart.map(getPrice));
  console.log('prices: ' + JSON.stringify(prices));
  console.log('total: ' + prices.reduce((sum, p) => sum + p, 0));

  const mixed = await Promise.all([1, Promise.resolve(2), 'three']);
  console.log(JSON.stringify(mixed));

  const empty = await Promise.all([]);
  console.log('empty: ' + JSON.stringify(empty));
}

main();
Try It Yourself

How It Works

  1. map() starts every lookup. cart.map(getPrice) returns an array of three promises that are all pending at the same time, and await pauses main until all of them fulfill.
  2. Use the array like any other. After the await, prices is a normal array, so reduce() adds it up to 10.
  3. Plain values and empty lists. The numbers and strings in mixed pass straight through. An empty list fulfills with [] instead of waiting forever.

Browser & Runtime Support

Promise.all() is part of ES2015 (ES6), together with the Promise object itself.

✓ Baseline · ES2015

Promise.all()

Supported in every modern browser, plus Node.js, Deno, and Bun. Internet Explorer has no promises at all.

Baseline Every modern browser
Google Chrome All modern versions
Full support
Mozilla Firefox All modern versions
Full support
Apple Safari All modern versions
Full support
Microsoft Edge All modern versions
Full support
Node.js All current releases
Supported
Deno All releases
Supported
Internet Explorer No native support
Not supported
Promise.all() Excellent

Bottom line: Safe everywhere you can use promises. For a report of every result instead of fail-fast behavior, use Promise.allSettled() (ES2020).

Frequently Asked Questions

Promise.all only waits. The tasks run at the same time because they were already started when you created their promises. Promise.all collects the results when they finish.
Always in the order of the input array. The first value belongs to the first promise, even if that promise finished last.
The returned promise rejects immediately with that first rejection reason. The other tasks keep running, but their results are ignored.
A promise that fulfills with an empty array. It does not stay pending.
Use Promise.allSettled when one failure should not hide the other results, for example when you show a report for several independent uploads or checks.

Next: Promise.allSettled()

Wait for every promise without failing fast, and get the status of each one.

allSettled() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful