Promise.all / any / race / allSettled — choose the right tool
Practice Promise combinators: all, any, race, allSettled. Learn success/failure behavior and when to use each one.
Promise.all / any / race / allSettled — choose the right tool is a free JavaScript Academy lesson on CoddyKit — lesson 3 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the JavaScript Academy learning path, one of 3 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Combinators overview
Goal: Learn four helpers and their behavior.
- all: wait for all; fail fast
- any: first success
- race: first settled (success/error)
- allSettled: results for all

Promise.all basics
Promise.all resolves with an array of results; a single rejection rejects the whole thing.
// Small helpers for examples
function delay(ms, value, shouldFail = false) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
if (shouldFail) reject(new Error(String(value)));
else resolve(value);
}, ms);
});
}
// Promise.all waits for all; rejects fast on first error
Promise.all([
delay(10, "A"),
delay(5, "B")
]).then(function (vals) {
console.log("all:", vals);
});

Promise.any basics
Promise.any resolves with the first success; it rejects only if all inputs reject.
// Promise.any gives the first fulfilled value
Promise.any([
delay(8, "ok-1"),
delay(3, "ok-2"),
delay(6, "ok-3")
]).then(function (v) {
console.log("any:", v);
}).catch(function (e) {
console.log("any failed:", e.message);
});

Promise.race basics
Promise.race picks whichever settles first: could be a resolve or a reject.
// Promise.race settles with the first to finish (success or error)
Promise.race([
delay(5, "win"),
delay(7, "boom", true)
]).then(function (v) {
console.log("race resolved:", v);
}).catch(function (e) {
console.log("race rejected:", e.message);
});

Promise.allSettled basics
Promise.allSettled always resolves with an array of status objects for every input.
// Promise.allSettled waits for all and reports each outcome
Promise.allSettled([
delay(4, "A"),
delay(6, "X", true)
]).then(function (results) {
console.log("allSettled:", results.map(function (r) { return r.status; }));
});

Which one to use?
Choosing:
- all: need all results; fail fast on any error.
- any: accept first success (fallback sources).
- race: pick first to finish (timeout patterns).
- allSettled: collect every outcome to inspect.

Combinator choice quiz
Quick check: First fulfilled result.

Recap
Recap: Use all for “need all”, any for “first success”, race for “first settled”, and allSettled to inspect every outcome without short-circuiting.

Frequently asked questions
Is the “Promise.all / any / race / allSettled — choose the right tool” lesson free?
Yes — the full text of “Promise.all / any / race / allSettled — choose the right tool” is free to read here on the web, and the JavaScript Academy course includes 3 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the JavaScript Academy course, upgrade to CoddyKit PRO.
What will I learn in “Promise.all / any / race / allSettled — choose the right tool”?
Practice Promise combinators: all, any, race, allSettled. Learn success/failure behavior and when to use each one. You practise JavaScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start JavaScript Academy?
No prior experience is required. JavaScript Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 3, so you can start here or from the beginning and move at your own pace.
How long does the “Promise.all / any / race / allSettled — choose the right tool” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this JavaScript Academy lesson?
Yes. Every JavaScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Event Loop & Task vs Microtask Basics
- Promises — States, Chaining, Error Handling
- Promise.all / any / race / allSettled — choose the right tool