Clean β’ Professional
Promise combinators are special methods that allow you to handle multiple promises simultaneously. They help manage asynchronous operations in bulk and provide different ways to react depending on how the promises settle.

const p1 = Promise.resolve(1);
const p2 = Promise.resolve(2);
const p3 = Promise.resolve(3);
Promise.all([p1, p2, p3]).then(results => console.log(results));
// Output: [1, 2, 3]
const p1 = new Promise(res => setTimeout(res, 100, "One"));
const p2 = new Promise(res => setTimeout(res, 50, "Two"));
Promise.race([p1, p2]).then(result => console.log(result));
// Output: "Two"
Β
const p1 = Promise.reject("Error 1");
const p2 = Promise.resolve("Success");
const p3 = Promise.reject("Error 2");
Promise.any([p1, p2, p3]).then(result => console.log(result));
// Output: "Success"
| Combinator | Behavior | Rejects If |
|---|---|---|
Promise.all | Waits for all promises to fulfill | Any promise rejects |
Promise.race | Settles as soon as first promise settles | First settled promise rejects |
Promise.any | Waits for first fulfilled promise | All promises reject |
Β