Lesson 19 — Promise.all
Wait for many at once
Promise.all([p1, p2, …]) starts from several Promises and gives one Promise that resolves to an array of all results. The results come back in the same order as you passed them, even if a later one finishes first. If any one fails, the whole thing fails.
const [a, b] = await Promise.all([fetchUser(), fetchPosts()]);
Why it matters: loading three things in parallel takes as long as the slowest one, not the sum of all three.
Wait for both delays together and print [ 1, 2 ] instead of two pending Promises.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based JavaScript Intermediate courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for JavaScript Intermediate books — check the publication year so the examples match current versions.
Search Amazon →