JavaScript Interview Questions
The JavaScript questions that come up most in frontend and full-stack interviews, with concise, correct answers. Read through them, then run a live mock interview to practice explaining them out loud.
11 common JavaScript questions
What's the difference between == and ===?
== compares after type coercion, while === compares value and type with no coercion. Prefer === to avoid surprises — for example 0 == "" is true but 0 === "" is false.
Explain closures.
A closure is a function that keeps access to variables from its outer (lexical) scope even after that outer function has returned. They power data privacy, factory functions, and callbacks that remember state.
What's the difference between var, let, and const?
var is function-scoped and hoisted as undefined; let and const are block-scoped with a temporal dead zone. const can't be reassigned (though objects it holds stay mutable). Prefer const, then let, and avoid var.
What is the event loop?
JavaScript runs on a single thread. The event loop moves queued callbacks onto the call stack when it's empty. Microtasks (promise callbacks) run before macrotasks (setTimeout) after each tick.
How does `this` work?
`this` depends on how a function is called: as a method it's the object, as a plain call it's undefined/global in strict mode, and arrow functions inherit `this` from their enclosing scope. call, apply, and bind set it explicitly.
What's the difference between null and undefined?
undefined means a variable was declared but never assigned; null is an intentional 'no value.' typeof undefined is "undefined", while typeof null is "object" — a long-standing language quirk.
What are promises and async/await?
A promise represents a future value that's pending, fulfilled, or rejected. async/await is sugar over promises that lets you write asynchronous code in a synchronous style; await pauses until the promise settles.
What is hoisting?
Declarations are processed before code runs. var and function declarations are hoisted (var initializes to undefined), while let and const are hoisted but left uninitialized in the temporal dead zone until their line executes.
What's the difference between map, forEach, filter, and reduce?
map returns a new transformed array, forEach just iterates and returns undefined, filter returns items that pass a test, and reduce folds the array into a single accumulated value.
What is a shallow copy versus a deep copy?
A shallow copy duplicates only top-level properties, so nested objects are shared by reference; a deep copy duplicates everything. {...obj} and Object.assign are shallow; structuredClone(obj) makes a deep copy.
Explain debouncing versus throttling.
Debounce waits until activity stops before running (good for search inputs); throttle runs at most once per interval (good for scroll or resize). Both limit how often an expensive handler fires.
Ready to practice out loud?
Reading answers is one thing — saying them under pressure is another. Run a free AI mock interview and get scored feedback.
Start a mock interview