The JavaScript event loop

One thread, never blocked: the call stack, the task queue, and the loop between them.

JavaScript runs one thing at a time on one call stack. Slow work (timers, network) is handed to the browser, and when it finishes, its callback waits in a queue.

The event loop is the doorman: whenever the call stack is empty, it takes the next callback from the queue and pushes it on. That single rule explains why a setTimeout(0) still waits for your code to finish, and why one blocking loop freezes a whole page.

Remember this

  • One call stack: only one thing runs at a time
  • Finished async work waits in the queue
  • The loop moves queue → stack only when the stack is empty

Got a different question? SeaThru generates a fresh video for any topic where systems talk or data structures move.

Ask your own question →

Keep learning