Promise.all() is a method in JavaScript that takes an array (or iterable) of promises and returns a single promise that resolves when all of the promises in the array have been resolved, or rejects if any one of the promises rejects.
Promise.all() returns a promise that resolves with an array of results (in the same order as the input promises).Promise.all() immediately rejects with the reason from the first rejected promise.
✅ All promises resolve → The output is an array of results [10, 20, 30].
❌ Since promise2 rejects, Promise.all() immediately rejects with "Failed" — the other promises' results are ignored.
You can use Promise.allSettled() if you want to handle both resolved and rejected promises:
Output:
✅ Promise.allSettled() returns the status of each promise, regardless of success or failure.