javascript mcqs

JavaScript MCQs (Multiple Choice Questions)

August 3rd, 2026
5499
10:00 Minutes

Preparing to become a Developer? This Top 70 JavaScript MCQs collection is your ultimate practice resource. It includes the most frequently asked and recently introduced JavaScript topics - ideal for interviews, coding assessments, and skill evaluation.

Note: Score 60% or higher to unlock an exclusive offer of up to 50% off on all self-paced JavaScript and Frontend courses.

Let's begin!

JavaScript Fundamentals

1. What is the output of typeof null in JavaScript?






2. Which of the following is NOT a JavaScript data type?






3. Which of the following keywords is used to declare a constant variable in ES6?






4. What will be the output of console.log(2 + '2' - 2)?






5. Which method converts a JSON string into a JavaScript object?






6. What does a closure in JavaScript do?






7. What is the result of calling a function before its declaration when using a function declaration?






8. Which statement about arrow functions is TRUE?






9. Which variable scope is created when using let?






10. What will be the output of the following?
let a = [1,2,3]; let b = a; b.push(4); console.log(a);






Test your JavaScript code on the Online JavaScript compiler for practice.

Functions, Scope & Closures

11. What does Function.prototype.bind() do?






12. Which is the correct way to create a private variable using closures?






13. What is the effect of the delete operator on object properties?






14. Which statement is TRUE about function expressions vs declarations?






15. What happens when you return from a function without a value?






ES6+ Syntax & Features

16. Which feature allows multi-line strings and interpolation with ${}?






17. What does the spread operator ... do when used with arrays?






18. Which of these is true about const with objects?






19. Which ES6 feature provides a concise way to define methods on object literals?






20. Which of the following was introduced for creating classes in ES6?






Asynchronous JavaScript & Event Loop

21. What does async/await help with?






22. Which function returns a Promise that resolves when the first promise resolves or rejects?






23. What part of the JavaScript runtime handles callbacks and timers outside the call stack?






24. Which queue processes microtasks like Promise.then callbacks?






25. What is the output order of this code?
console.log('A'); setTimeout(()=>console.log('B'),0); Promise.resolve().then(()=>console.log('C')); console.log('D');






DOM & Browser APIs

26. Which method selects the first matching element using a CSS selector?






27. Which property provides access to the element’s parent in the DOM?






28. Which event method prevents the default browser action?






29. Which API is best for making HTTP requests in modern browsers?






30. Which Web API allows you to store key-value pairs in the browser persistently?






ES Modules & Tooling

31. Which statement imports the default export from a module?






32. Which bundler is commonly used for modern JavaScript apps?






33. What is tree-shaking in bundlers?






34. Which file typically defines project scripts and dependencies for Node.js projects?






35. Which command initializes a new npm project interactively?






Node.js Basics

36. Which global object in Node.js provides access to the file system module?






37. Which method reads a file asynchronously in Node.js using callbacks?






38. Which command installs a package and saves it to package.json dependencies?






39. Which statement describes Node.js?






40. Which pattern is commonly used in Node.js to handle asynchronous flows with improved readability?






Security & Best Practices

41. Which practice helps prevent Cross-Site Scripting (XSS) attacks?






42. Which function is considered dangerous and can lead to security risks if used with untrusted input?






43. Which header helps mitigate clickjacking attacks when sent from server?






44. What is CORS (Cross-Origin Resource Sharing) primarily used for?






45. Which is a secure way to store secrets for client-side code?






Performance & Optimization

46. Which technique helps reduce initial page load by loading JavaScript only when needed?






47. What is debouncing useful for in front-end development?






48. Which browser API helps do heavy work off the main thread?






49. Which property indicates layout shift for measuring visual stability (CLS)?




50. Which technique reduces network requests by combining files?






You Can Also Check:

1. JavaScript Interview Questions
2. Python Interview Questions
3. Java MCQs
4. Python MCQs
5. Cyber Security MCQs

Debugging & Tooling

51. Which browser tool can help you inspect network requests and responses?






52. Which source maps setting helps map minified code back to original source for debugging?






53. Which tool can help find security vulnerabilities in npm packages?






54. Which linting tool is widely used for JavaScript code quality checks?






55. Which testing framework is commonly used for unit tests in JavaScript?






Latest Features & Emerging Topics

56. What does optional chaining ?. do?






57. What is the Nullish Coalescing operator (??) used for?






58. Which feature helps with true-private fields in classes?






59. Which new-ish API enables background tasks and can be used for offline capabilities?






60. Which proposal aims to improve server-first rendering and streaming in modern web apps (commonly referenced in 2023-2025 ecosystem)?






Common Interview Topics

61. What is prototypal inheritance in JavaScript?






62. Which is a common reason for memory leaks in JavaScript apps?






63. What is event delegation?






64. Which statement about JSON.stringify is TRUE?






65. Which of these is a correct way to shallow clone an object in modern JS?






66. Which operator checks both type and value equality?






67. Which built-in method returns the index of the first occurrence of a specified value in an array?






68. Which array method creates a new array with the results of calling a provided function on every element?






69. Which of the following is true about use strict?






70. What is the purpose of data attributes (attributes prefixed with data-) in HTML when used with JavaScript?






Advanced & Scenario-Based Questions

71. What will be logged?
console.log([] == false);






72. Which method is used to freeze an object?






73. What is the purpose of WeakMap?






74. What does the optional catch binding allow?






75. Which hook is used in React for side effects?






76. What is hydration in SSR?






77. Which HTTP status indicates successful creation?






78. What is memoization used for?






79. What does BigInt allow?






80. What does Array.prototype.reduce() return?






81. Which method converts a string to an integer in JavaScript?






82. What will typeof NaN return?






83. Which array method modifies the original array?






84. What is the default value of an uninitialized variable declared with let?






85. Which keyword is used to handle errors?






86. Which symbol is used for rest parameters?






87. Which method checks if an array includes a value?






88. What does Object.keys() return?






89. Which statement creates a Promise?






90. Which lifecycle method runs after DOM content loads in vanilla JS?






91. Which operator spreads object properties?






92. Which method converts an object into JSON string?






93. Which method removes the last element from an array?






94. Which operator is used for exponentiation?






95. Which object represents the browser window?






96. Which tool transpiles modern JavaScript for older browsers?






97. Which function delays execution for specified milliseconds?






98. Which keyword stops loop execution?






99. Which operator is used to check if property exists in object?






100. Which API is used to observe DOM changes?






101. What is the primary purpose of WebSockets?






102. Which JavaScript method creates a deep copy of most built-in objects without using JSON serialization?






103. What is the primary advantage of AbortController when using the Fetch API?






104. Which recently standardized method groups iterable elements based on a callback result?






105. Which Promise method introduced recently simplifies creating a Promise along with its resolve and reject functions?






106. Which API is specifically designed for processing large streams of data without loading everything into memory?






107. Which JavaScript runtime is written in Rust and includes a secure permission model by default?






108. Which runtime is widely recognized for its extremely fast package installation and startup performance?






109. Which Vite feature significantly improves development speed compared to traditional bundlers?






110. A user types into a search box, triggering dozens of API requests every second. What is the best optimization technique?






111. A web application gradually becomes slower after users navigate through multiple pages. Which issue is the most likely cause?






112. Which technique helps prevent supply-chain attacks in JavaScript projects?






113. Which browser API allows JavaScript code to run in a separate thread?






114. Which JavaScript feature allows a module to pause execution until asynchronous imports complete?






115. Which browser feature enables smooth transitions between page states without full page reloads?






116. Which method converts an asynchronous iterable into an array?






117. Which security mechanism helps reduce XSS attacks by restricting the execution of untrusted scripts?






118. Which browser API allows developers to prioritize background tasks so they do not block user interactions?






119. A Node.js application becomes unresponsive while processing a very large JSON file. What is the best solution?






120. During an interview, you're asked how to improve the loading performance of a modern JavaScript application. Which answer is the MOST complete?






Additional Advanced JavaScript MCQs

121. Which method returns a new array containing only the elements that satisfy a specified condition?






122. What will Object.is(NaN, NaN) return?






123. Which method checks whether at least one element in an array passes a provided test?






124. What does Promise.allSettled() do?






125. Which operator can be used to conditionally assign a value only when the current value is null or undefined?






126. Which JavaScript collection stores unique values of any type?






127. What will [1, 2, 3].at(-1) return?






128. Which method creates a new array with one level of nested arrays flattened?






129. Which syntax dynamically imports a JavaScript module?






130. Which browser API is commonly used to efficiently detect when an element enters or leaves the viewport?






131. Which method can be used to determine whether an array contains a specific value?






132. What is the main purpose of requestAnimationFrame()?






133. Which JavaScript feature allows an object to customize its behavior for operations such as property access and assignment?






134. What will Array.from("JS") return?






135. Which statement about JavaScript generators is correct?






136. Which syntax is used to delegate execution from one generator to another iterable?






137. Which API provides high-resolution timestamps useful for measuring JavaScript performance?






138. What is the purpose of Object.entries()?






139. Which statement creates a Promise that is already resolved with the value 10?






140. What does the finally() method of a Promise do?






141. A large computation is freezing the user interface in a browser application. Which solution is most appropriate?






142. You need to execute multiple independent asynchronous operations concurrently and fail if any one of them fails. Which method should you use?






143. A page contains thousands of dynamically created list items that require click handling. Which approach is generally most efficient?






144. You need to cancel an API request when a user navigates away from a page. Which JavaScript API is most appropriate?






145. An application needs to process data as it arrives over the network instead of waiting for the complete response. Which API is best suited for this?






146. A function is called repeatedly during window resizing and causes performance issues. Which technique is generally appropriate for limiting its execution rate?






147. You need to make a shallow copy of an array without modifying the original array. Which option is valid?






148. A developer wants to safely access user.profile.address.city when some properties may not exist. Which syntax is most appropriate?






149. You want to clone a complex object containing nested objects, Maps, Sets, and Date objects. Which built-in method is generally the best choice?






150. A modern JavaScript application needs smaller initial bundles and wants certain modules to load only when users need them. Which approach is most appropriate?






About the Author
Sanjay Prajapat
About the Author

Sanjay Prajapat is a Data Engineer and technology writer with expertise in Python, SQL, data visualization, and machine learning. He simplifies complex concepts into engaging content, helping beginners and professionals learn effectively while exploring emerging fields like AI, ML, and cybersecurity in today’s evolving tech landscape.

Drop Us a Query
Fields marked * are mandatory
×

Your Shopping Cart


Your shopping cart is empty.