What is Event Loop?
See how the call stack, Web APIs, microtasks and the task queue decide the order your code runs in.
Type a tool name, format or task
See how the call stack, Web APIs, microtasks and the task queue decide the order your code runs in. Interactive step-by-step animation with JavaScript code, complexity and front-end use cases.
Loading animation...
See how the call stack, Web APIs, microtasks and the task queue decide the order your code runs in. Synchronous code runs on the call stack until it is empty. Promise callbacks wait in the microtask queue; timers and events wait in the task queue. When the stack is empty the event loop runs every microtask, then takes one task, and repeats. Time complexity: n/a. Space complexity: n/a. Explains why setTimeout(fn, 0) runs after promises, why long tasks freeze the page, and most async bugs.
See how the call stack, Web APIs, microtasks and the task queue decide the order your code runs in.
Time: n/a. Space: n/a.
Explains why setTimeout(fn, 0) runs after promises, why long tasks freeze the page, and most async bugs.
No. This converter runs in your browser for ordinary use, so the input is not sent to a backend by this tool.
Keep working without searching again.
Press Play and follow each call, timer and promise.
runs one thing at a time
empty
empty
empty
empty
Event loop
Stack empty? Run nextTick, then microtasks, then one macrotask.
Running your script
nothing printed yet
The script starts: main() is on the call stack.
Tap the logs in the order you think they will print, then press Play to check.