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

  1. 1What is JavaScript?
  2. 2What is the difference between var, let, and const?
  3. 4What are the data types in JavaScript?
  4. 5What is the typeof operator?
  5. 6What is the difference between == and ===?
  6. 7What is a function in JavaScript?
  7. 8What is an arrow function?
  8. 9What is a callback function?
  9. 11What is scope?
  10. 12What is block scope?
  11. 13What is global scope?
  12. 16What is NaN?
  13. 17What is the difference between null and undefined?
  14. 18What are template literals?
  15. 19What is destructuring?
  16. 20What are default parameters?
  17. 21What is the spread operator?
  18. 22What is the rest operator?
  19. 23What is an array?
  20. 24What is an object?
  21. 25How do you loop through arrays?
  22. 26What is the map() method?
  23. 27What is the filter() method?
  24. 29What is forEach()?
  25. 30Difference between map and forEach?
  26. 31What is JSON?
  27. 33What is 'strict mode'?
  28. 35What is truthy and falsy?
  29. 37What is optional chaining?
  30. 38What is nullish coalescing?
  31. 49What is an IIFE?
  32. 59What is a shallow copy?
  33. 61Difference between find() and filter()?
  34. 62Difference between slice() and splice()?
  35. 63Difference between push() and unshift()?
  36. 64What is includes()?
  37. 65What is indexOf()?
  38. 68What is reverse()?
  39. 69What is every()?
  40. 70What is some()?
  41. 71What is a Promise?
  42. 73What is async/await?
  43. 79What is Axios?
  44. 80What is an API call?
  45. 81What is the DOM?
  46. 86What is addEventListener?
  47. 88What is querySelector?
  48. 89What is classList?
  49. 91Difference: LocalStorage vs SessionStorage?
  50. 94setTimeout vs setInterval?
  51. 95What is clearTimeout?
  52. 97What is the Location API?
  53. 112What are side effects?
  54. 114What are Higher-Order Functions?
  55. 119What is Callback Hell?
  56. 127What is Lazy Loading?
  57. 135Difference: AuthN vs AuthZ?
  58. 136What are ES6 Modules?
  59. 139Nullish (??) vs OR (||)?
  60. 141What is Unit Testing?
  61. 149What is the purpose of Object.freeze()?
  62. 161Reverse a string
  63. 162Check if a string is a palindrome
  64. 163Find duplicate numbers in an array
  65. 164Remove duplicates from an array
  66. 169Create a polyfill for map()
  67. 170Create a polyfill for filter()
  68. 175Generate Fibonacci sequence
  69. 176Find the factorial of a number
  70. 179Group an array of objects by key
  71. 180Count frequency of elements in array
  72. 182Chunk an array
  73. 184Find max and min in one pass
  74. 185Intersection of two arrays
  75. 186Union of two arrays
  76. 192Convert an array of pairs to an object
  77. 193Convert an object to an array of pairs
  78. 197Implement Function.prototype.apply

Medium101 medium JavaScript questions

  1. 3What is hoisting in JavaScript?
  2. 10What is a closure?
  3. 14What is local scope?
  4. 28What is the reduce() method?
  5. 32What is JSON.parse() and JSON.stringify()?
  6. 34What is type coercion?
  7. 36What is short-circuiting?
  8. 39What is dynamic typing?
  9. 40What is immutability?
  10. 41What is an execution context?
  11. 42What is the Call Stack?
  12. 43What is the Event Loop?
  13. 44What is the difference between Microtasks and Macrotasks?
  14. 45What is debounce?
  15. 46What is throttle?
  16. 47What is currying?
  17. 48What is function composition?
  18. 50What is recursion?
  19. 51What is a prototype in JavaScript?
  20. 52What is the prototype chain?
  21. 53Difference between Class and Prototype inheritance?
  22. 54What is inheritance in JS?
  23. 55What is Object.create()?
  24. 56What is bind()?
  25. 57What is call()?
  26. 58What is apply()?
  27. 60What is a deep copy?
  28. 66What is flat()?
  29. 67What is sort()?
  30. 72What are the states of a Promise?
  31. 74How to handle errors in async/await?
  32. 75What is Promise.all()?
  33. 76What is Promise.race()?
  34. 77What is Promise.allSettled()?
  35. 78What is the Fetch API?
  36. 82What is DOM manipulation?
  37. 83What is event bubbling?
  38. 84What is event capturing?
  39. 85What is event delegation?
  40. 87Difference between innerHTML and textContent?
  41. 90What is dataset?
  42. 92What are Cookies?
  43. 93What are Web APIs?
  44. 96What is the History API?
  45. 98What is the Navigator object?
  46. 104What is WeakMap?
  47. 105What is WeakSet?
  48. 106What is Symbol?
  49. 107What is BigInt?
  50. 110How to implement currying?
  51. 111What are Pure Functions?
  52. 113What are immutability patterns?
  53. 115What is Memoization?
  54. 117What is the Async Queue?
  55. 118What is the Microtask Queue?
  56. 120What is Promise Chaining?
  57. 121What is the Singleton Pattern?
  58. 122What is the Factory Pattern?
  59. 123What is the Observer Pattern?
  60. 124What is the Module Pattern?
  61. 125What is the Pub-Sub Pattern?
  62. 126What is Code Splitting?
  63. 128What is Tree Shaking?
  64. 129Debounce vs Throttle use cases?
  65. 133What is Sanitization?
  66. 134What is JWT?
  67. 137What is Dynamic Import?
  68. 138Optional Chaining deep usage?
  69. 140What are Private Fields?
  70. 142What is Jest?
  71. 143What is Mocking?
  72. 144What is Snapshot Testing?
  73. 145What is Integration Testing?
  74. 147What is the temporal dead zone (TDZ)?
  75. 148What is function.prototype.apply used for?
  76. 150What is the purpose of Object.seal()?
  77. 151What is a Generator function?
  78. 152What is iterator protocol?
  79. 154What is a Worker Thread?
  80. 157How to detect a memory leak in Chrome?
  81. 158What is a polyfill?
  82. 159What is a transpiler?
  83. 160What is the difference between shallow and deep freeze?
  84. 165Flatten a nested array
  85. 166Deep clone an object
  86. 167Implement a debounce function
  87. 168Implement a throttle function
  88. 171Create a polyfill for reduce()
  89. 173Create a custom event emitter
  90. 177Implement Binary Search
  91. 178Sort an array (Bubble Sort)
  92. 181Merge two sorted arrays
  93. 183Shuffle an array (Fisher-Yates)
  94. 187Implement currying function
  95. 188Implement function composition
  96. 189Retry an API call on failure
  97. 190Implement a rate limiter
  98. 191Deep compare two objects
  99. 194Flatten a nested object
  100. 196Implement Function.prototype.call
  101. 199Implement Promise retry logic

Hard21 hard JavaScript questions

  1. 15What is the 'this' keyword?
  2. 99What is CORS?
  3. 100What is the Same-Origin Policy?
  4. 101How does the event loop work internally?
  5. 102What is Garbage Collection?
  6. 103What are memory leaks?
  7. 108What is Proxy?
  8. 109What is Reflect?
  9. 116How do Promises work internally?
  10. 130JS Optimization techniques?
  11. 131What is XSS?
  12. 132What is CSRF?
  13. 146How to use Proxy for validation?
  14. 153What is async generator?
  15. 155What is SharedArrayBuffer?
  16. 156What is Atomic operation in JS?
  17. 172Implement a simple Promise
  18. 174Implement an LRU cache
  19. 195Implement Function.prototype.bind
  20. 198Implement an Async Queue
  21. 200Build a mini React-like state system