JavaScript · Middle · Question 19 of 75

How does Promise.any differ from Promise.race?

Explanation

Promise.any rejects only if all of them reject, with an AggregateError. Promise.race adopts the outcome of the fastest - that's how timeouts are done: Promise.race([fetch(url), timeout(5000)]).

Further reading

Problem with a question

JavaScript · Middle · question 19

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz