Your product could be here, in front of thousands of JavaScript developers. Sponsor this spot →
JavaScript Quiz

What is the difference between Promise.all and Promise.allSettled?

Do you know what will be the output of this code?

JavaScript
Promise.allSettled([Promise.resolve(1), Promise.reject(2)])
  .then((results) => console.log(results.map((r) => r.status)));
Show answer and explanation

The answer is ["fulfilled", "rejected"].

allSettled resolves with one object per promise: { status: "fulfilled", value } or { status: "rejected", reason }. It never rejects itself.

Take the full quiz Next question →

More Promises & Async questions

  1. Why does an arrow function in setTimeout keep this?
  2. Why does a Promise run before setTimeout 0?
  3. What does an async function return in JavaScript?
  4. What runs first after await in JavaScript?
  5. Is the Promise constructor callback synchronous?

Related topics