Recall & Review
beginner
What is sequential execution in JavaScript?
Sequential execution means running code one step at a time, in order. Each step waits for the previous one to finish before starting.
Click to reveal answer
beginner
What does parallel execution mean?
Parallel execution means running multiple tasks at the same time, so they can finish faster by working together.
Click to reveal answer
intermediate
How does JavaScript handle parallel execution since it has a single thread?
JavaScript uses asynchronous features like promises and async/await to start tasks that run in the background, allowing other code to run without waiting.
Click to reveal answer
intermediate
What is the role of
Promise.all() in parallel execution?Promise.all() lets you run multiple promises at the same time and wait for all of them to finish before continuing.Click to reveal answer
intermediate
Give an example of sequential vs parallel execution using async functions.
Sequential:
await task1(); await task2(); runs task2 after task1 finishes.<br>Parallel: await Promise.all([task1(), task2()]); runs both tasks at the same time.Click to reveal answer
Which of these best describes sequential execution?
✗ Incorrect
Sequential execution means tasks run one by one, each waiting for the previous to finish.
What JavaScript feature helps run tasks in parallel?
✗ Incorrect
Promises and async/await allow JavaScript to handle tasks asynchronously, enabling parallel execution.
What does
Promise.all() do?✗ Incorrect
Promise.all() runs promises together and waits until all complete.If you write
await task1(); await task2();, how do tasks run?✗ Incorrect
Using await one after another runs tasks sequentially.
Why is parallel execution useful?
✗ Incorrect
Parallel execution helps programs finish tasks faster by running them simultaneously.
Explain the difference between sequential and parallel execution in JavaScript.
Think about waiting for tasks to finish or running them together.
You got /3 concepts.
How does
Promise.all() help with parallel execution?It collects many promises and waits for all.
You got /3 concepts.