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.
- iterable: An iterable object such as Array, Map, String, etc.
Output: As promise2 was faster it prints two.
As promise2 is faster than promise1, so it rejects and doesn’t print anything.
- Google Chrome 6.0 and above
- Internet Explorer 9.0 and above
- Mozilla 4.0 and above
- Opera 11.1 and above
- Safari 5.0 and above