Caffeinated Coder
Book an appointment
Lesson 18 · Async JavaScript

The event loop

JavaScript runs your code on one thread, one thing at a time, so it never stops to wait. Follow an eight-line script that prints start, end, promise, timeout: watch frames pile up on the call stack, two callbacks wait in the task queue and the microtask queue, and the event loop move them back onto the stack once it is empty, microtasks first.

10 min10 steps5 questionsIntermediate
Fig 18 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.