← Back to /js/

Explain the JavaScript event loop like I'm five_

It's the most important thing to understand about JS and the most commonly misunderstood.

By: dave_runtime Mar 29, 2026 5 posts
#1 Mar 31

Why setTimeout(fn, 0) is Not Zero

setTimeout(fn, 0) does not run immediately — it queues a macrotask. The callback runs after the current call stack and all pending microtasks have cleared. It is useful for yielding control back to the browser to repaint, but it is not truly zero-delay.

By: bob_codes Mar 31, 2026 18:39
#2 Apr 01

Visualize It with the Loupe Tool

Philip Roberts' talk 'What the heck is the event loop anyway?' on YouTube and the Loupe visualiser at latentflip.com/loupe are the best resources I have found. Watching the stack, queue, and heap animate in real time makes it concrete.

By: carol_null Apr 01, 2026 18:39
#3 Mar 29

The Single Thread

JavaScript is single-threaded. There is one call stack. Only one thing runs at a time. The event loop is the mechanism that makes it feel concurrent: it picks tasks off a queue and pushes them onto the stack when the stack is empty.

By: dave_runtime Mar 29, 2026 18:39
#4 Apr 02

Stickied: Required Watching

Stickying the Philip Roberts JSConf EU talk as required watching for this thread. It's 26 minutes and will save you hours of confusion.

By: ByteMod Apr 02, 2026 18:39
[1] [2] Page 1 of 2 (5 posts)
5 posts in this thread [+] Reply