You watch a conference talk about the JavaScript event loop. Someone draws boxes on a whiteboard, or a newer explainer animates two colored queues. setTimeout versus Promise.then suddenly makes sense. Two weeks later a teammate pastes a four-line snippet in review and asks what logs first, and the order falls apart in your head.
I've been through that cycle more times than I want to admit. The event loop isn't hard because the pieces are fancy. It's hard because they only make sense together, and most write-ups walk you through them one at a time, then never ask you again.
This is the version that finally stuck for me, and how I keep it from leaking out between interviews and late-night bugs.
The call stack runs one thing at a time
JavaScript in the browser (and the mental model most of us use in Node) has a single call stack. A function starts, it may call another function, and when a function returns it pops off. While the stack still has frames on it, nothing else in your script runs.…