Nearby lessons

18 of 22

JavaScript: Promise.all()

📌 What is Promise.all()?

Promise.all() takes an array of promises and returns a single Promise that resolves when all of the input promises have resolved, or rejects if any promise rejects. It's commonly used for running multiple asynchronous tasks in parallel.

1️⃣ All Promises Resolve Successfully

When all promises resolve, Promise.all() returns an array of results in the same order.

Example02
🚀Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

2️⃣ One Promise Fails and Others Resolve

If any promise is rejected, Promise.all() immediately rejects and skips the remaining results.

Example03
🚀Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🧠 Test Your Knowledge

3 Questions
Progress: 0 / 3