JavaScript·Intermediate·Coding·1 min read
How do Promise.all and Promise.allSettled differ?
Short interview answer
Promise.all fulfills with ordered values when every input fulfills and rejects as soon as one input rejects. allSettled waits for every input and reports each outcome, making it appropriate when partial failure is expected and every result matters.
Example
await Promise.all([a, b, c]);// -> [va, vb, vc], or rejects on the first rejection
await Promise.allSettled([a, b, c]);// -> [{status:'fulfilled', value}, {status:'rejected', reason}, ...]Key takeaway
Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.