Standard built-ins

Promise.any()

Try the free JavaScript compiler

Fulfills with the first successful input. If every input rejects, rejects with AggregateError containing rejection reasons in input order. Empty input rejects.

Formal Syntax & Structure

javascript syntaxjavascript
Promise.any(iterable)

Parameters & Attributes

NameTypeDescription
iterableIterableValues or promises.

Return Value

Promise

First fulfillment or aggregate rejection.

Working Example

Example Snippetjavascript
Promise.any([Promise.reject("bad"),Promise.resolve("ok")]).then(console.log);
JavaScript Reference