200 JavaScript interview questions and answers
JavaScript interview questions on closures, scope, the event loop, promises and async/await, prototypes, this, modules, and the tricky output questions interviewers love.
Easy78 easy JavaScript questions
- 1What is JavaScript?
- 2What is the difference between var, let, and const?
- 4What are the data types in JavaScript?
- 5What is the typeof operator?
- 6What is the difference between == and ===?
- 7What is a function in JavaScript?
- 8What is an arrow function?
- 9What is a callback function?
- 11What is scope?
- 12What is block scope?
- 13What is global scope?
- 16What is NaN?
- 17What is the difference between null and undefined?
- 18What are template literals?
- 19What is destructuring?
- 20What are default parameters?
- 21What is the spread operator?
- 22What is the rest operator?
- 23What is an array?
- 24What is an object?
- 25How do you loop through arrays?
- 26What is the map() method?
- 27What is the filter() method?
- 29What is forEach()?
- 30Difference between map and forEach?
- 31What is JSON?
- 33What is 'strict mode'?
- 35What is truthy and falsy?
- 37What is optional chaining?
- 38What is nullish coalescing?
- 49What is an IIFE?
- 59What is a shallow copy?
- 61Difference between find() and filter()?
- 62Difference between slice() and splice()?
- 63Difference between push() and unshift()?
- 64What is includes()?
- 65What is indexOf()?
- 68What is reverse()?
- 69What is every()?
- 70What is some()?
- 71What is a Promise?
- 73What is async/await?
- 79What is Axios?
- 80What is an API call?
- 81What is the DOM?
- 86What is addEventListener?
- 88What is querySelector?
- 89What is classList?
- 91Difference: LocalStorage vs SessionStorage?
- 94setTimeout vs setInterval?
- 95What is clearTimeout?
- 97What is the Location API?
- 112What are side effects?
- 114What are Higher-Order Functions?
- 119What is Callback Hell?
- 127What is Lazy Loading?
- 135Difference: AuthN vs AuthZ?
- 136What are ES6 Modules?
- 139Nullish (??) vs OR (||)?
- 141What is Unit Testing?
- 149What is the purpose of Object.freeze()?
- 161Reverse a string
- 162Check if a string is a palindrome
- 163Find duplicate numbers in an array
- 164Remove duplicates from an array
- 169Create a polyfill for map()
- 170Create a polyfill for filter()
- 175Generate Fibonacci sequence
- 176Find the factorial of a number
- 179Group an array of objects by key
- 180Count frequency of elements in array
- 182Chunk an array
- 184Find max and min in one pass
- 185Intersection of two arrays
- 186Union of two arrays
- 192Convert an array of pairs to an object
- 193Convert an object to an array of pairs
- 197Implement Function.prototype.apply
Medium101 medium JavaScript questions
- 3What is hoisting in JavaScript?
- 10What is a closure?
- 14What is local scope?
- 28What is the reduce() method?
- 32What is JSON.parse() and JSON.stringify()?
- 34What is type coercion?
- 36What is short-circuiting?
- 39What is dynamic typing?
- 40What is immutability?
- 41What is an execution context?
- 42What is the Call Stack?
- 43What is the Event Loop?
- 44What is the difference between Microtasks and Macrotasks?
- 45What is debounce?
- 46What is throttle?
- 47What is currying?
- 48What is function composition?
- 50What is recursion?
- 51What is a prototype in JavaScript?
- 52What is the prototype chain?
- 53Difference between Class and Prototype inheritance?
- 54What is inheritance in JS?
- 55What is Object.create()?
- 56What is bind()?
- 57What is call()?
- 58What is apply()?
- 60What is a deep copy?
- 66What is flat()?
- 67What is sort()?
- 72What are the states of a Promise?
- 74How to handle errors in async/await?
- 75What is Promise.all()?
- 76What is Promise.race()?
- 77What is Promise.allSettled()?
- 78What is the Fetch API?
- 82What is DOM manipulation?
- 83What is event bubbling?
- 84What is event capturing?
- 85What is event delegation?
- 87Difference between innerHTML and textContent?
- 90What is dataset?
- 92What are Cookies?
- 93What are Web APIs?
- 96What is the History API?
- 98What is the Navigator object?
- 104What is WeakMap?
- 105What is WeakSet?
- 106What is Symbol?
- 107What is BigInt?
- 110How to implement currying?
- 111What are Pure Functions?
- 113What are immutability patterns?
- 115What is Memoization?
- 117What is the Async Queue?
- 118What is the Microtask Queue?
- 120What is Promise Chaining?
- 121What is the Singleton Pattern?
- 122What is the Factory Pattern?
- 123What is the Observer Pattern?
- 124What is the Module Pattern?
- 125What is the Pub-Sub Pattern?
- 126What is Code Splitting?
- 128What is Tree Shaking?
- 129Debounce vs Throttle use cases?
- 133What is Sanitization?
- 134What is JWT?
- 137What is Dynamic Import?
- 138Optional Chaining deep usage?
- 140What are Private Fields?
- 142What is Jest?
- 143What is Mocking?
- 144What is Snapshot Testing?
- 145What is Integration Testing?
- 147What is the temporal dead zone (TDZ)?
- 148What is function.prototype.apply used for?
- 150What is the purpose of Object.seal()?
- 151What is a Generator function?
- 152What is iterator protocol?
- 154What is a Worker Thread?
- 157How to detect a memory leak in Chrome?
- 158What is a polyfill?
- 159What is a transpiler?
- 160What is the difference between shallow and deep freeze?
- 165Flatten a nested array
- 166Deep clone an object
- 167Implement a debounce function
- 168Implement a throttle function
- 171Create a polyfill for reduce()
- 173Create a custom event emitter
- 177Implement Binary Search
- 178Sort an array (Bubble Sort)
- 181Merge two sorted arrays
- 183Shuffle an array (Fisher-Yates)
- 187Implement currying function
- 188Implement function composition
- 189Retry an API call on failure
- 190Implement a rate limiter
- 191Deep compare two objects
- 194Flatten a nested object
- 196Implement Function.prototype.call
- 199Implement Promise retry logic
Hard21 hard JavaScript questions
- 15What is the 'this' keyword?
- 99What is CORS?
- 100What is the Same-Origin Policy?
- 101How does the event loop work internally?
- 102What is Garbage Collection?
- 103What are memory leaks?
- 108What is Proxy?
- 109What is Reflect?
- 116How do Promises work internally?
- 130JS Optimization techniques?
- 131What is XSS?
- 132What is CSRF?
- 146How to use Proxy for validation?
- 153What is async generator?
- 155What is SharedArrayBuffer?
- 156What is Atomic operation in JS?
- 172Implement a simple Promise
- 174Implement an LRU cache
- 195Implement Function.prototype.bind
- 198Implement an Async Queue
- 200Build a mini React-like state system