← 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 30

Macro Tasks vs Micro Tasks

There are two queues. Microtasks (Promise callbacks, queueMicrotask) drain completely before the next macrotask (setTimeout, setInterval, I/O callbacks) runs. This is why a resolved Promise callback always fires before a setTimeout(fn, 0).

By: alice_dev Mar 30, 2026 18:39
#2 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
#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 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
[1] [2] Page 1 of 2 (5 posts)
5 posts in this thread [+] Reply