JavaScript · Middle · Question 17 of 75
How does Promise.all behave if one of the promises rejects?
- ✓Correct answer: It rejects immediately with that error; the other results are lost
- 2It waits for all promises and returns an array of results and errors
- 3It ignores the error and returns only the successful results
Explanation
Promise.all is "all or nothing". The other operations aren't cancelled; their results are just no longer needed. If all outcomes matter, use Promise.allSettled; for the first success, Promise.any; for the first settled, Promise.race.