Lesson content
Read, practise, then check your understanding
JavaScript jobs run to completion on a call stack. Hosts queue tasks for timers, events, and I/O; Promise reactions and queueMicrotask use the microtask queue.
Ordering
console.log("start");
setTimeout(() => console.log("task"), 0);
Promise.resolve().then(() => console.log("microtask"));
console.log("end");
// start, end, microtask, task
After a task, the host drains microtasks before another task and usually before rendering. Recursive microtasks can starve input/rendering; long synchronous work blocks everything. Split CPU work, yield appropriately, or move suitable computation to workers. Node has related phases and additional queues, so exact host ordering rules matter.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.