Tricky JavaScript Interview Questions: Output Traps

Tricky JavaScript interview questions that ask you to predict the output are a staple of screening rounds at Google, Meta, and top tech companies. They test whether you understand the underlying runtime mechanics when multiple language features interact simultaneously.

Instead of merely showing the final console output, our interactive stepper highlights the active line of code alongside real-time call stack frames and scope state. Understand why common misconceptions occur and build rock-solid confidence under interview pressure.

The four lessons group the traps output questions are built from: hoisting and the temporal dead zone, how this is decided at call time, the order of synchronous code, microtasks and timers, and implicit type coercion and object mutation. Each snippet is short enough for an interviewer to type in a minute, and most candidates answer it wrong at first glance.

Work through them by predicting the output before revealing it and by naming the rule that produces each line; the rule is what carries over to the next snippet you have not seen.

Tricky JavaScript Interview Questions: 4 lessons

Frequently asked questions

What does typeof null return in JavaScript?

'object'. It is a bug from the first version of JavaScript that cannot be fixed without breaking existing code. Check for null with value === null.

Why does a resolved Promise callback run before setTimeout(fn, 0)?

Promise callbacks are microtasks and setTimeout callbacks are macrotasks. When the current synchronous code finishes, the event loop empties the whole microtask queue before it takes the next macrotask, so the Promise callback runs first.

What does [] + {} return in JavaScript?

The string "[object Object]". Both operands are converted to primitives, [] to an empty string and {} to "[object Object]", and + with a string operand concatenates them.