VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-promise-any-method/

⇱ JavaScript Promise any() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Promise any() Method

Last Updated : 8 Jun, 2026

JavaScript Promise any() method is a static method that takes an array of promises as a parameter and returns the first fulfilled promise. It returns a rejected value when all of the promises in the array return rejects or if the array is empty. When all the promises are rejected an AggregateError is returned which contains the reason for rejection.

Syntax:

Promise.any(iter)

Parameters: It takes only one parameter.

  • iter: It is iterable of promises.

Return Value: It returns a promise which is:

  • rejected if the parameter which is passed is empty
  • asynchronously fulfilled if the first fulfilled promise is encountered
  • asynchronously rejected if all the promises return a reject. In this case, an AggregateError is returned.

Example 1: This example, shows the basic use of Promise.any() method.


Example 2: This example shows how the promise is rejected in any method.

We have a complete list of Javascript Promise methods, to check those please go through the article.

Comment
Article Tags: