Q17: What is the difference between Promise.all, Promise.allSettled, Promise.race, and Promise.any?

  • Promise.all(): Resolves when all resolve; rejects immediately if any reject.
  • Promise.allSettled(): Resolves when all settle (fulfilled or rejected).
  • Promise.race(): Settles as soon as any promise settles.
  • Promise.any(): Resolves as soon as any promise fulfills; rejects if all reject.
Key Takeaways
  • Promise.all fails fast on initial rejection.

  • Promise.allSettled guarantees tracking outcome states for every promise.

Knowledge Check

Which Promise combinator rejects ONLY if ALL input promises reject?