JavaScript interview questions test everything from core language fundamentals to framework-specific knowledge. This page covers every JavaScript interview resource on TheCodeForge — from closures and prototypes to React and Node.js.
JavaScript interviews concentrate on a small number of mechanisms that the language's syntax deliberately hides: how the event loop schedules work, how closures capture their environment, how this is determined, and how prototypes resolve properties. Almost every question, including the famously tricky ones, is one of those four.
That is why the output-prediction questions are so popular. Asking what a snippet logs, in order, tests all four at once — and reveals immediately whether someone has a mental model or a set of memorised rules.
The runtime has a call stack, a microtask queue and a macrotask queue. Synchronous code runs to completion on the stack. Then all microtasks — promise callbacks, queueMicrotask — drain, including any queued while draining. Only then does one macrotask run: a setTimeout callback, an I/O event.
That ordering is the entire answer to the classic puzzle, and being able to narrate it beats reciting the output.
Nearly every this question resolves by applying these in precedence order, and saying that you are doing so is itself the answer the interviewer wants.
1. An arrow function has no this; it uses the enclosing lexical scope, and bind cannot change it. 2. Called with new: this is the newly-created object. 3. Called with call, apply or bind: whatever was supplied. 4. Called as a method — obj.fn() — this is obj. 5. Otherwise: undefined in strict mode and modules, the global object outside it.
const f = obj.method; f() has no obj, because rule 4 applies at the call site and not at assignment. That is why React class components needed bind in the constructor.| Topic | Asked as | Have ready |
|---|---|---|
| Closures | Write a counter / a memoise function / debounce | That the inner function keeps the variable itself alive, not a copy of its value |
| Prototypes | How does inheritance work without classes? | Property lookup walks the prototype chain; class is syntax over it |
| == versus === | What does == do? | Type coercion with a specific algorithm. Use ===; the one idiomatic exception is x == null to catch both null and undefined |
| Promises | Implement a retry, or explain all vs allSettled vs race | all rejects on the first failure; allSettled never rejects; race settles on the first to settle either way |
| Modules | ESM versus CommonJS | ESM imports are static and hoisted, enabling tree shaking; CommonJS require is dynamic and synchronous |
| Debounce / throttle | Implement one from scratch | Debounce waits for quiet; throttle allows one call per interval. Know which suits search-as-you-type versus scroll |
this rules as you go — the reasoning is what is being assessed.require is synchronous, clustering versus worker threads, and how to handle backpressure. For pure frontend roles, a working familiarity with the tooling is usually enough.74 interview topics across coding patterns, HR questions, aptitude and more.
View All Interview Topics →