Iterates over an iterableObject of Promises and stops at the first one that fulfills. The resulting value from that fulfilled Promise is resolved in the returned Promise object.



The iterableObject is usually an array of Promise objects. If the array is empty, a Promise object that resolves into an empty array will be returned.

Example #1

If the iterable object is empty or all the Promises witin are rejected, an AggregateError is thrown.

.then((values) => console.log(values))
.catch((err) => console.log(err)))// Output: [AggregateError: All promises were rejected]
.finally(() => console.log("Operations on Promise.any() have finished."))

Example #2

Below is an array of promises contains 3 Promise objects.

  • 2 of them, promiseA and promiseB, will be rejected.
  • The other one, promiseC, will fulfill and resolve with a message.

Using Promise.all, the value of the first successfully resolved Promise will be logged to the console.

const promiseA = new Promise((resolve, reject) => {
const promiseB = new Promise((resolve, reject) => {
reject('Always fails!');
const promiseC = new Promise((resolve, reject) => {
const promises = [promiseA, promiseB, promiseC];
.then((result) => {
console.log(result); // Output: Success!
.catch((err) => {
.finally(() => console.log('Operations on Promise.any() have finished.'));


Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn JavaScript on Codecademy