There is a particular kind of interview humiliation reserved for experienced JavaScript developers: getting a "basics" question wrong. Years of shipping production code do not automatically inoculate you against the language's sharper edges, because most of us learn just enough of them to avoid trouble and never look closer. Here are the concepts that still trip up senior developers, and why they are worth revisiting before your next interview.
Closures in a loop
The classic. What does this log?
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 0);
}
It logs 3, 3, 3 — not 0, 1, 2. Because var is function-scoped, every callback closes over the same i, and by the time the timeouts fire, the loop has finished and i is 3. Swap var for let, which is block-scoped and creates a fresh binding each iteration, and you get 0, 1, 2. Senior developers know closures exist; this question checks whether they understand what a closure captures — a variable, not a value.
The value of this
this is not determined by where a function is defined but by how it is called, and that single fact produces endless confusion. The same function can have four different this values depending on whether it's called as a method, as a plain function, with new, or via call/apply/bind. Arrow functions change the rules again: they have no this of their own and inherit it from the enclosing scope, which is exactly why they're so useful for callbacks. An interviewer asking about this is really asking whether you understand JavaScript's invocation model, not whether you've memorised a rule.
The event loop, and microtasks vs macrotasks
Most seniors can say "JavaScript is single-threaded and asynchronous." Fewer can predict this:
console.log('A');
setTimeout(() => console.log('B'), 0);
Promise.resolve().then(() => console.log('C'));
console.log('D');
The order is A, D, C, B. Synchronous code runs first (A, D). Then the event loop drains the microtask queue — promise callbacks — before the macrotask queue where setTimeout lives, so C comes before B despite the zero delay. Understanding that promises jump the queue ahead of timers is the difference between using async and understanding it.
== vs ===, and coercion
Everyone knows to prefer ===. The gotcha is being able to explain the coercion rules == triggers — why 0 == '' is true, why null == undefined is true but null == 0 is false, and why [] == ![] is true. You will rarely rely on these in good code, but an interviewer uses them to test whether you actually understand type coercion or merely avoid it. "I always use ===" is a fine practice and an incomplete answer.
Hoisting and the temporal dead zone
var declarations are hoisted and initialised as undefined, so using one before its line gives undefined, not an error. let and const are also hoisted but not initialised — they sit in the "temporal dead zone" until their declaration runs, and touching them there throws a ReferenceError. Many senior developers describe hoisting as "declarations move to the top" and get caught when asked why let behaves differently. The precise mental model matters.
Why interviewers still ask these
None of this is trivia for its own sake. Each question maps to a real source of production bugs — a stale closure in an event handler, a this that silently became undefined, a race between a promise and a timeout, an accidental coercion. Interviewers ask them because the developers who understand these mechanisms write more predictable code and debug faster when something goes wrong.
If it has been a while since you looked closely, working through a deeper JavaScript question bank is worth the afternoon — not to memorise answers, but to rebuild the precise mental models that day-to-day coding lets you get away with fuzzing. These fundamentals matter even more in framework code, where how these show up in React work — stale closures in hooks, this in class components, effect timing — turns "interview trivia" into the exact bugs you fight in real applications.
The bottom line
The JavaScript questions that trip up senior developers are not hard because they're advanced. They're hard because they probe the mechanics underneath habits we've automated. Revisit closures, this, the event loop, coercion, and hoisting with fresh eyes before an interview, and you'll not only answer more crisply — you'll understand your own code a little better than you did before.