Methods of Promises in JavaScript

In this short article, we’ll show you the list of the methods of Promises in JavaScript.

Methods of Promises in JavaScript

  1. Promise.all()
  2. Promise.allSettled()
  3. Promise.any()
  4. Promise.race()

1. Promise.all()

The Promise.all() method takes an array (an iterable) of promises and returns a single Promise that resolves to an array of the results.

2. Promise.allSettled()

The Promise.allSettled() method returns a promise that resolves after all of the given promises have either been fulfilled or rejected, with an array of objects that each describes the outcome of each promise.

3. Promise.any()

Promise.any() takes an iterable of Promise objects and, as soon as one of the promises in the iterable fulfills, returns a single promise’s value.

If no promises in the iterable fulfill, then the returned promise is rejected.

4. Promise.race()

The Promise.race() method returns a promise that fulfills or rejects as soon as one of the promises in an iterable fulfills or rejects, with the value or reason from that promise.

Here you will also find more information about the Promise.

I hope you find this article helpful.
Thank you for reading. Happy Coding..!! 🙂

If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *