JavaScript Interview Questions Every Frontend Engineer Should Know
The JavaScript interview questions and concepts frontend engineers are most often asked to explain or implement — closures, the event loop, this, promises, debounce and more, with concise answers.
JavaScript Interview Questions Every Frontend Engineer Should Know
Frontend interviews lean hard on core JavaScript — not to catch you on trivia, but to see whether you understand the runtime you work in every day. These are the concepts most commonly asked to explain or implement. Learn to reason about them out loud, not just recite definitions.
Concepts you're expected to explain
What is a closure?
A closure is a function bundled with references to its surrounding lexical scope. It lets a function "remember" variables from where it was defined even after that scope has returned. Closures power data privacy, function factories, and patterns like debounce and memoize.
How does this work?
this is determined by how a function is called, not where it's defined: method call → the object; plain call → undefined in strict mode (or the global object otherwise); call/apply/bind → the value you pass; arrow functions → inherited from the enclosing scope (they have no own this).
Explain the event loop, microtasks and macrotasks.
The call stack runs synchronous code; async callbacks queue up. Promise callbacks go on the microtask queue, setTimeout/setInterval on the macrotask queue. After each macrotask, the loop drains all microtasks before rendering or the next macrotask — which is why a Promise.then runs before a setTimeout(0) scheduled just before it. We cover this in depth in the event loop, explained.
Promises vs async/await.
async/await is syntax over promises. await pauses the async function until the promise settles, making sequential async code read like synchronous code — but remember it still yields to the event loop. Know Promise.all (parallel, fails fast), Promise.allSettled (never rejects) and Promise.race.
== vs ===, null vs undefined, hoisting.
=== compares without coercion (prefer it); == coerces and surprises. undefined means "not assigned"; null is an explicit "no value." var declarations and function declarations hoist; let/const are hoisted but in a temporal dead zone until assigned.
Utilities you're expected to implement
These "implement X from scratch" prompts double as machine-coding warmups:
- debounce and throttle — closures + timers. See debounce vs throttle.
- deep clone — recursion over arrays/objects (handle nested structures).
Promise.all— resolve results in order, reject on first error.- curry — collect args until arity is met.
- memoize — cache by serialized arguments.
- an event emitter —
on/off/emitover a listener map.
The interviewer watches how you build: do you preserve this and arguments in debounce? Do you handle the empty case in Promise.all? Structure and edge cases score more than speed.
How to actually get good at these
Explaining is not the same as implementing. Practise writing these utilities under a timer and running them against tests. Frontend Interview Prep includes a Mock Interview mode with sandboxed coding challenges (debounce, deep clone, Promise.all, LRU cache and more) that run your solution against real tests, plus concept questions and gap tracking across JavaScript, React and system design.
Common mistakes
- Reciting a definition but failing to reason about a concrete snippet's output.
- Forgetting
this/arguments in debounce, or the empty-array case inPromise.all. - Confusing microtasks and macrotasks when predicting execution order.
- Using
==and getting bitten by coercion.
Frequently asked questions
What JavaScript topics are most common in frontend interviews?
Closures, this binding, the event loop (microtasks vs macrotasks), promises/async-await, and implementing utilities like debounce, throttle, deep clone and Promise.all. These are widely reported, commonly-discussed themes — not company-specific claims.
Should I memorise answers?
No — understand the runtime well enough to reason about any snippet and implement the utilities from scratch. Interviewers probe follow-ups that rote answers can't survive.
Where can I practise implementing these with real tests?
The Mock Interview mode in Frontend Interview Prep runs your solutions against sandboxed tests, so you get real pass/fail feedback rather than self-grading. Pair it with the 2026 frontend interview roadmap.
Practise coding challenges with real, sandboxed tests, free.
Everything runs in your browser. Nothing leaves your device.
Open Frontend Interview PrepGo deeper on async — read the guide.