Ganesan C
Difference between Promise.race vs Promise.any

What is Promise in JavaScript? Diffrenec between Promise.race vs Promise.any?

By Ganesan C in JavaScript on Aug 13 2021
  • Ganesan C
    Aug, 2021 17

    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.

    Promise.any() takes an iterable of Promise objects and, as soon as one of the promises in the iterable fulfills, returns a single promise that resolves with the value from that promise. If no promises in the iterable fulfill , then the returned promise is rejected with an AggregateError.

    • 1
  • RomanJay Almaza
    Sep, 2021 22

    Promise. race is settled as soon as any of the promises you feed it settle, whether they are fulfilled or rejected. Promise. any is settled as soon as any of the promises you feed it is fulfilled or they are all rejected, in which case it’s rejected with an AggregateError .

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS