CKTIS / JavaScript
Promise.all — one result from multiple promises
Promise.all returns a single promise for all elements of an iterable. If iteration completes without error and all elements yield values, the promise fulfills with an array of results in input order. The first observed input rejection rejects the combined promise. An exception thrown during iteration can also reject it, even if no input promise rejects. The method does not cancel the remaining operations.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
Promise.all(iterable)Promise.all(iterable) is a static method accepting a synchronous iterable, such as an array. It returns a new promise fulfilled with an array of values when every element succeeds. Plain values are accepted; objects with a callable then method are assimilated as promises.
Result order follows input order, not completion order. Empty input produces a promise already fulfilled with []; callbacks passed to .then() still run asynchronously. For nonempty input containing plain values or fulfilled promises, fulfillment of the result is also asynchronous.
The first observed rejection rejects the combined promise with the same reason, without waiting for the others to succeed. This does not cancel their work. Handle rejection with .catch() or try/catch around await. The method does not invoke supplied functions: to collect their results, invoke them and pass the returned promises.
In the example, first fulfills after second, but the result preserves input order. The number 3 appears unchanged in the array, and sync is printed before the result.
Examples
const first = Promise.resolve().then(() => "A");
const second = Promise.resolve("B");
Promise.all([first, second, 3]).then((values) => {
console.log(JSON.stringify(values));
});
console.log("sync");Result
sync ["A","B",3]
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.