The Event Loop, in Pictures
The call stack runs one function at a time, finished timers wait their turn in the task queue, and the event loop moves the next one onto the stack only when the stack is empty, which is why setTimeout(fn, 0) runs after the code around it.
Updated

- Category
- JavaScript
- Level
- Journeyman
- Tags
- Call Stack, Callback Hell, Event Loop (javascript), JavaScript, Run-to-Completion, Task Queue