JavaScriptAdvanced#async#promises

Difference between Promise.all, allSettled, race and any?

all resolves with every value but rejects on the first failure. allSettled always resolves with a status per promise. race settles with the first promise to settle either way. any resolves with the first fulfilment and rejects only if all fail.

Example
await Promise.all([a, b]);        // fails fast
await Promise.allSettled([a, b]); // [{status:'fulfilled'},{status:'rejected'}]
await Promise.race([a, timeout]); // whichever finishes first

Related Questions

1
JavaScriptIntermediate#async

How does async/await work?

Open
2
JavaScriptIntermediate#async#performance

How do you run async calls in parallel with async/await?

Open
3
JavaScriptBeginner#async

What is callback hell and how do you avoid it?

Open