JavaScript Promise.any() Explained

JavaScript Logo

Promise.any() – Returns the first fulfilled promise. Ignores rejections unless all fail.

๐Ÿ‘‰ Syntax

Promise.any([p1, p2]).then(firstSuccess => {
  // first fulfilled only
});

๐Ÿงช Example

Promise.any([
  Promise.reject('Fail'),
  Promise.resolve('Win')
]).then(console.log);

Comments