Interview prep

JavaScript Interview Questions

JavaScript interviews test the event loop, closures and asynchronous control flow before any framework specifics.

Questions and answers

01Explain the event loop.

The call stack runs synchronously; completed async work queues callbacks. Microtasks (promises) drain fully after each task, before the next macrotask (timers, IO), which is why a promise chain runs before a setTimeout(0).

02What is a closure and where does it bite you?

A closure captures variables from its defining scope. The classic bug is capturing a loop variable declared with var — every callback sees the final value; let creates a fresh binding per iteration.

03Difference between == and ===?

== applies type coercion before comparing; === compares type and value. Use === unless you deliberately want null and undefined to compare equal.

04How does prototypal inheritance work?

Objects hold a link to a prototype object; property lookup walks that chain until it finds a match. class syntax is sugar over the same mechanism.

05What is the difference between debounce and throttle?

Debounce delays execution until activity stops — good for search input. Throttle guarantees at most one call per interval — good for scroll and resize handlers.

How to answer these well

Interviewers are not grading recall — they are checking whether you've hit the failure mode the question describes. Anchor every answer to something you actually shipped or debugged with JavaScript.

Say the trade-off out loud. "I'd use X here, but it costs Y under Z conditions" scores higher than a clean textbook definition every time.

Roles asking for JavaScript

Related prep