🟨 JavaScript Intermediate

What is Promise.all() vs Promise.allSettled()?

Answer

Promise.all(promises) takes an array of Promises and returns a new Promise that resolves when ALL input Promises resolve, with an array of their resolved values. If ANY Promise rejects, Promise.all immediately rejects with that error — other pending Promises are abandoned (though they still run). Use when all operations must succeed: const [user, posts] = await Promise.all([fetchUser(), fetchPosts()]). Promise.allSettled(promises) (ES2020) waits for ALL Promises to settle (fulfill or reject) and always resolves with an array of result objects: {status: "fulfilled", value: ...} or {status: "rejected", reason: ...}. Never rejects. Use when you want results from all operations regardless of individual failures: sending multiple analytics events, bulk operations where partial success is acceptable. Related: Promise.race() settles with the first settled Promise; Promise.any() (ES2021) settles with the first FULFILLED Promise (ignores rejections unless all fail).