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.
== 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.
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.
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.
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.
`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.
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.
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.
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.
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.
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.
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.
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