JavaScript is forgiving enough that people ship it for years without understanding closures, this, or the event loop. These questions surface who actually knows the language.
Hiring a JavaScript developer is easy. Telling a real one from a convincing résumé is the hard part — and it’s most of what we do. These are grouped by level, because the same question that stretches a junior is a warm-up for a senior.
Junior JavaScript interview questions
0–2 years
Core language mechanics.
What is the difference between let, const and var?
var is function-scoped and hoisted; let/const are block-scoped with a temporal dead zone, and const forbids reassignment (though objects it points to stay mutable).
Thinks const makes an object immutable, or uses var with no idea why it’s discouraged.
What is the difference between == and ===?
=== compares without type coercion; == coerces types first, which produces surprising results. A good answer defaults to ===.
Uses == everywhere and can’t explain coercion pitfalls.
What are truthy and falsy values?
Falsy values are false, 0, "", null, undefined, NaN; everything else is truthy, including [] and {}.
Thinks empty array or object is falsy.
What is a closure?
A function that retains access to variables from the scope it was created in, even after that scope has returned; the basis for data privacy and callbacks.
Can use closures accidentally but cannot define or explain one.
What’s the difference between null and undefined?
undefined means a variable has been declared but not assigned; null is an explicit “no value.” They know typeof null is the historical "object".
Treats them as interchangeable with no nuance.
How does this work?
It is determined by how a function is called: the object before the dot, the global/undefined in plain calls, bound explicitly with call/apply/bind, and lexically in arrow functions.
Believes this is fixed at definition time for normal functions.
What is the difference between map, forEach and filter?
map returns a new transformed array, filter returns a subset, forEach returns nothing and is for side effects.
Uses map for side effects and ignores the returned array.
What does JSON.parse/JSON.stringify do, and its limits?
Serialise to and from JSON text; limits include losing functions, undefined, and Date becoming a string, plus failing on circular references.
Unaware that dates and undefined don’t round-trip.
Mid-level JavaScript interview questions
2–5 years
Async model and prototypes.
Explain the event loop, call stack and task queues.
Synchronous code runs on the call stack; async callbacks are queued and run when the stack clears, with microtasks (promises) draining before macrotasks (timers). They can predict logging order.
Cannot explain why a promise resolves before a setTimeout(0).
What is the difference between promises and async/await?
async/await is syntactic sugar over promises that reads synchronously; errors are caught with try/catch instead of .catch(). They know await only pauses the async function, not the whole program.
Thinks await blocks the entire thread.
How do you run async operations in parallel?
Promise.all for all-or-nothing, Promise.allSettled when you need every result regardless of failures; awaiting in a loop serialises them unnecessarily.
Awaits independent calls sequentially in a for loop.
What is prototypal inheritance?
Objects delegate to a prototype via the prototype chain; property lookups walk that chain, and class is sugar over it.
Thinks JS classes are like Java classes with no prototype underneath.
What are call, apply and bind?
All set this; call/apply invoke immediately (args list vs array), bind returns a new bound function.
Cannot say how they differ.
What is debouncing vs throttling?
Debounce delays until activity stops (e.g. search input); throttle caps the rate (e.g. scroll handlers). They match the technique to the use case.
Uses the terms interchangeably.
What are common causes of memory leaks in JS?
Forgotten timers and listeners, closures holding large objects, detached DOM nodes, and unbounded caches or global variables.
Thinks the garbage collector makes leaks impossible.
What does &&, || and ?? return?
They return one of their operands, not a boolean; ?? only falls back on null/undefined, unlike || which falls back on any falsy value.
Assumes || and ?? behave identically.
Senior JavaScript interview questions
5+ years
Performance, patterns and deep semantics.
How do you optimise the performance of a JS-heavy page?
Reduce main-thread work, split and lazy-load bundles, avoid layout thrash, debounce expensive handlers, and move heavy computation to Web Workers — after profiling.
Optimises by intuition without measuring in DevTools.
What is the module system story in JS?
ES modules are static and tree-shakeable with live bindings; CommonJS is dynamic and synchronous. They understand bundling and interop concerns.
No grasp of the difference or why bundlers exist.
How does garbage collection work in V8?
A generational, mark-and-sweep collector; short-lived objects are collected cheaply in the young generation. They avoid retaining references unnecessarily.
Believes setting a variable to null forces immediate collection.
When and why would you use a Web Worker?
To move CPU-bound work off the main thread and keep the UI responsive, communicating via message passing since there is no shared DOM access.
Tries to touch the DOM from a worker.
What are generators and where are they useful?
Functions that can pause and resume with yield, useful for lazy sequences, custom iterators and controlled async flows.
Never encountered them and can’t reason about lazy iteration.
How do you handle errors in async code robustly?
try/catch around awaits, handling rejected promises, a global unhandledrejection handler, and never swallowing errors silently.
Lets promise rejections go unhandled.
What is the difference between shallow and deep copying?
A shallow copy (spread, Object.assign) copies top-level references; nested objects are shared. Deep copies need structuredClone or a recursive approach.
Spreads an object and is surprised nested mutations leak.
How do you keep a large JS codebase maintainable without a framework?
Clear module boundaries, pure functions, consistent state management, TypeScript or JSDoc types, and tests. They think in architecture, not files.
Relies on global state and huge files.
Build and score a full interview with our free interview scorecard tool, browse the full question hub, or see how we interview engineers.