Using Promise.any() in JavaScript

Using Promise.any() in JavaScript

ยท

1 min read

Featured on daily.dev

In this video, I'll discuss

  • What is Promise.any() method?
  • Syntax
  • What parameters does this method accept?
  • What does it return?
  • and finally What is the main difference between Promise.any() & Promise.race() methods?

I am going to explain all of these points using lots of examples so that you can clearly understand it and then maybe you can start using it in your own projects based on your use cases.

Description

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. This method is useful for returning the first promise that fulfills.

Syntax

Promise.any(iterable);

Parameters

iterable - an iterable object, such as an Array.

Please check out this video where all the points are explained in full details:


Wrap Up

I hope you will find this video useful and learn something new in the process. If you want to learn more HTML, CSS, JavaScript and web development tips & tricks, please make sure to subscribe on YouTube!