🟨 JavaScript Interview Questions
Master JavaScript interviews with questions on closures, promises, async/await, and ES6+ features
15-Minute JavaScript Cheatsheet
Quick reference for last-minute interview preparation
🎯 Core Concepts
✨ ES6+ Features
let/const - Block scoped variablesarrow => - Lexical this binding... - Spread/rest operator`template` - Template literalsdestructuring - Extract values⏳ Async JavaScript
📦 Objects & Arrays
map/filter/reduce - Array methodsObject.keys/values/entriesObject.assign/spread - MergeJSON.parse/stringify🔗 Prototypes & Classes
__proto__ - Object's prototypeclass - Syntactic sugarextends - Class inheritancesuper - Parent reference🌐 DOM & Events
addEventListenerpreventDefault/stopPropagation⚠️ Common Interview Gotchas
What is the difference between var, let, and const?
Easyvar, let, and const are used for variable declaration but have different scoping and hoisting behaviors.
Explain closures in JavaScript with examples
MediumA closure is a function that remembers its lexical scope even when executed outside that scope. It "closes over" its outer variables.
Explain the event loop in JavaScript
HardThe event loop is JavaScript's mechanism for handling asynchronous operations. It continuously checks the call stack and processes callbacks from the task queue.
What is 'this' keyword and how does it work?
Mediumthis refers to the execution context. Its value depends on how a function is called, not where it's defined.
Explain Promises and async/await
MediumPromises represent eventual completion of async operations. async/await is syntactic sugar that makes async code look synchronous.
What is prototypal inheritance in JavaScript?
HardJavaScript uses prototypal inheritance where objects inherit directly from other objects through the prototype chain.
Explain == vs === and type coercion
Easy== performs type coercion before comparison, while === checks both value and type without coercion.
What are higher-order functions? Explain map, filter, reduce
MediumHigher-order functions take functions as arguments or return functions. map, filter, and reduce are essential array methods.
What is event delegation and bubbling?
MediumEvent bubbling is when events propagate from child to parent. Event delegation uses this to handle events on a parent instead of individual children.
What is hoisting in JavaScript?
EasyHoisting moves declarations to the top of their scope during compilation. Variables and functions are hoisted differently.
Explain spread and rest operators
EasyThe spread operator ... expands iterables into individual elements. The rest operator collects multiple elements into an array.
What are JavaScript modules (import/export)?
MediumES6 modules allow splitting code into separate files with explicit imports and exports for better organization and reusability.
Explain destructuring in JavaScript
EasyDestructuring extracts values from arrays or properties from objects into distinct variables using a concise syntax.
What is the difference between null and undefined?
Easyundefined means a variable has been declared but not assigned a value. null is an intentional assignment representing "no value."
What are generators and iterators in JavaScript?
HardGenerators are functions that can pause execution and resume later. Iterators are objects that define a sequence and return values one at a time.
What are WeakMap and WeakSet?
HardWeakMap and WeakSet hold "weak" references to objects, allowing them to be garbage collected when no other references exist.
What is the Proxy object in JavaScript?
HardProxy wraps an object and intercepts operations like property access, assignment, and function calls, enabling custom behavior.
How do you handle errors in JavaScript?
MediumJavaScript provides try-catch-finally for synchronous errors and Promise rejection for async errors. Custom error classes enable specific error handling.
What is debouncing and throttling?
MediumDebouncing delays execution until after a pause in calls. Throttling limits execution to at most once per time period. Both optimize performance.
What are JavaScript design patterns?
HardDesign patterns are reusable solutions to common programming problems. JavaScript commonly uses Module, Singleton, Factory, Observer, and other patterns.
Interview Tips for JavaScript
- ✓ Understand closures and how they capture variables
- ✓ Know the event loop, call stack, and task queues
- ✓ Master Promises and async/await patterns
- ✓ Understand prototypal inheritance vs class syntax
- ✓ Know the differences between var, let, and const
- ✓ Practice array methods: map, filter, reduce
- ✓ Understand 'this' binding in different contexts
- ✓ Be ready to implement debounce, throttle, and other utilities