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.

Code Example
PREVIEW READY
Loading Editor...
Live Preview

2️⃣ One Promise Fails and Others Resolve

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

Code Example
PREVIEW READY
Loading Editor...
Live Preview

🧠 Test Your Knowledge

3 Questions

Progress: 0 / 3
Keep Going!AJS - AJAX