JavaScript Interview Questions With AI-Powered Feedback
Practice the JavaScript questions that actually appear in frontend engineering interviews — event loop, closures, async patterns, and live coding challenges. Get evaluated like a senior engineer, with rubric-based feedback on every answer.
Types vs interfaces, generics, utility types (Partial, Pick, Omit), type narrowing, and structural typing.
Common JavaScript interview questions and answers
The fundamentals interviewers return to, with the short answer you would give out loud.
How does the this keyword work in JavaScript?
The value of this is decided by how a function is called, not where it is written. A plain call gives undefined in strict mode, a method call gives the object before the dot, call, apply and bind set it explicitly, and new binds it to the fresh object. Arrow functions have no this of their own and use the one from the surrounding scope, which is why they suit callbacks inside methods.
Every object has an internal link to another object, its prototype. When you read a property that is not on the object itself, the engine follows that chain until it finds it or reaches null. Classes are syntax over the same mechanism, and Object.create lets you set the prototype directly.
=== compares value and type with no conversion. == converts types first, which gives surprises like 0 == '' being true, while null == undefined is true and null == 0 is false. Use === by default. Object.is is the one to know for NaN and for telling +0 from -0.
Return a new promise. Wrap each input in Promise.resolve so plain values work, store each result at its original index, and resolve with the array once all have finished. Reject immediately with the first rejection, and resolve straight away with an empty array when the input is empty. Order of results must match order of inputs, not the order they finish.
What is the difference between a shallow and a deep copy?
Spread and Object.assign copy only the top level, so nested objects are still shared. structuredClone makes a deep copy of most built-in types, including Dates, Maps and Sets, but throws on functions. A JSON round trip drops undefined and functions and turns Dates into strings, so it is rarely the right answer.
Instead of attaching a listener to every child, attach one to a common parent and use event.target to see which child was hit. It needs fewer listeners and works for elements added later. Know the caveats: stopPropagation can block it, and events like focus and blur do not bubble, so use focusin and focusout.
What JavaScript topics are covered in frontend interviews?
Frontend JavaScript interviews cover: the event loop and microtask queue, closures and scope, prototypal inheritance and the prototype chain, async patterns (Promises, async/await, Promise.all), var/let/const and the temporal dead zone, this binding and call/apply/bind, ES6+ features (destructuring, spread, generators, modules), and coding challenges like implementing debounce, throttle, deep clone, and curry.
How does the JavaScript event loop work?
The JavaScript event loop continuously checks the call stack and task queues. When the call stack is empty, it first processes all microtasks (Promise callbacks, queueMicrotask) before picking the next macrotask (setTimeout, setInterval, I/O). This means Promise .then() callbacks always run before setTimeout callbacks, even with a 0ms delay. Understanding this ordering is critical for frontend interviews.
What is a closure and when is it used in JavaScript?
A closure is a function that retains access to its outer scope's variables even after the outer function has returned. Closures are used for: data encapsulation and private variables, factory functions, memoization, event handlers that need access to loop variables, and implementing module-like patterns. Common interview questions ask you to implement debounce, throttle, or once() using closures.
What JavaScript coding challenges are common in interviews?
Common JavaScript coding challenges include: implementing debounce and throttle, deep clone an object, flatten a nested array, implement Promise.all and Promise.race, curry a function, implement a simple event emitter, memoize a function, implement bind/call/apply, flatten an object, and implement a LRU cache. For frontend roles, challenges also include DOM manipulation and building small utilities.