JavaScript Interview Questions
55 free, interview-ready questions with clear answers and code. Work through them top to bottom, or jump to any topic.
JavaScript Interview Q&A — The Complete Question Bank
- →What is the difference between var, let and const?
- →What is hoisting? What is the Temporal Dead Zone?
- →What is the difference between primitive and reference types?
- →What is the difference between null and undefined?
- →What are the quirks of typeof, and how do you reliably check types?
- →What is NaN and how do you check for it?
- →== vs === — what's the difference?
- →Which values are falsy in JavaScript?
- →Explain JavaScript's implicit coercion rules. What does 1 + '2' - 1 give?
- →Why does [] == ![] evaluate to true?
- →How do you explicitly convert between types?
- →What is a closure and why is it useful?
- →What is lexical scope and the scope chain?
- →What is an IIFE and when would you use one?
- →What is currying? Implement a curry that supports add(1)(2)(3) and add(1,2)(3).
- →Why does a var loop with setTimeout print the same number, and how do you fix it?
- →What are higher-order functions? Give examples.
- →What is a pure function and why does it matter?
- →How is the value of `this` determined?
- →What's the difference between call, apply and bind?
- →How do arrow functions treat `this` differently?
- →What does it mean to 'lose this', and how do you fix it?
- →Implement your own bind (Function.prototype.myBind).
- →What is prototypal inheritance?
- →What's the difference between __proto__ and prototype?
- →Shallow copy vs deep copy — how do you make each?
- →What's the difference between Object.freeze and Object.seal?
- →What does the `new` keyword do under the hood?
- →What's the difference between an ES6 class and a constructor function?
- →What is optional chaining and how does it help?
- →Explain the event loop.
- →What's the difference between microtasks and macrotasks?
- →What is a Promise and what are its states?
- →Promise.all vs allSettled vs race vs any?
- →How does async/await relate to promises?
- →How do you handle errors in async code, and what is an unhandled rejection?
- →What's the output: console.log + setTimeout + Promise + await?
- →Debounce vs throttle — what's the difference and when do you use each?
- →What's the difference between map and forEach?
- →How does reduce work and when would you use it?
- →Which array methods mutate, and what's the sort() gotcha?
- →How do you remove duplicates from an array?
- →What's the difference between slice and splice?
- →find vs filter, and some vs every?
- →What is destructuring? Show array and object examples.
- →What's the difference between spread and rest?
- →Optional chaining vs nullish coalescing — and why not just use ||?
- →When would you use Map/Set over plain objects/arrays?
- →What are generators and iterators?
- →Named vs default exports in ES modules?
- →What's the difference between event bubbling and capturing?
- →What is event delegation and why is it useful?
- →preventDefault vs stopPropagation?
- →localStorage vs sessionStorage vs cookies?
- →What's the difference between defer and async on a script tag?
