518 JavaScript Interview Questions to Crack Placements in 2027

Published October 2026 · avivashishta.com

You commented js, so here are all 518 questions. They come from sudheerj/javascript-interview-questions, and every one has a full written answer, most with code, in the repo. Each link below jumps straight to its answer. I pulled the list from the repo's README on 2 October 2026 and sorted the questions by topic myself, so a few could fit in more than one group.

The short version: 518 questions in 11 topics, plus 87 "what's the output?" coding exercises at the end of the repo. Master closures, promises and the event loop first, do the coding exercises, then build the 3 small things below. That's what you talk about in the interview.

The repo

sudheerj/javascript-interview-questions ~27K ★

A long-running list of JavaScript interview questions with written answers and code, from the same author as the React interview questions repo. Free to read on GitHub.

The 4 I'd start with

  1. Closures and hoisting. What are closures, What is hoisting and the Temporal Dead Zone. The first thing every JS round tests.
  2. Promises and async/await. 50 questions in the async section, starting with What is a promise.
  3. The event loop. What is the event loop and tasks in the event loop. If you can draw it, you can answer half the async questions.
  4. The 87 coding exercises. "What's the output?" questions at the end of the repo. The most common JS round in Indian frontend interviews.

What to build to prove you get it

  1. Your own debounce function, then use it on a search box.
  2. Your own version of bind, using call or apply.
  3. A fetch wrapper that retries failed requests with promises.

You don't need all 518. You need to explain closures without saying "it's when a function remembers".

Jump to a topic

Variables, types and operators (59) · Functions, scope and closures (64) · Objects, classes and prototypes (100) · Arrays, strings and collections (60) · Async: promises, callbacks and the event loop (50) · ES6+ syntax and modules (19) · Control flow and syntax (16) · Browser, DOM and web APIs (94) · Errors and debugging (7) · Tooling, engines and the ecosystem (25) · Everything else (24)

All 518 questions, by topic (518)

Variables, types and operators (59)

  1. What is the difference between == and === operators
  2. What is the purpose of the let keyword
  3. What is the difference between let and var
  4. What is the reason to choose the name let as a keyword
  5. How do you redeclare variables in a switch block without an error
  6. What is the Temporal Dead Zone
  7. What is a strict mode in javascript
  8. Why do you need strict mode
  9. How do you declare strict mode
  10. What is the purpose of double exclamation
  11. What is the purpose of the delete operator
  12. What is typeof operator
  13. What is null value
  14. What is the difference between null and undefined
  15. What is isNaN
  16. What are the differences between undeclared and undefined variables
  17. What is the purpose of void 0
  18. Is JavaScript a case-sensitive language
  19. How do you validate an email in javascript
  20. How do you display the current date in javascript
  21. Is the !-- notation represents a special operator
  22. How do you assign default values to variables
  23. What are the benefits of keeping declarations at the top
  24. What are the benefits of initializing variables
  25. How do you generate random integers
  26. What would be the result of 1+2+'3'
  27. Can I use reserved words as identifiers
  28. How do you convert date to another timezone in javascript
  29. What is a conditional operator in javascript
  30. What are various operators supported by javascript
  31. What are the bitwise operators available in javascript
  32. What is a spread operator
  33. What are primitive data types
  34. What are the two types of loops in javascript
  35. What is an Unary operator
  36. What is the comma operator
  37. What is the advantage of the comma operator
  38. What is typescript
  39. What are the differences between javascript and typescript
  40. What are the advantages of typescript over javascript
  41. What is a void operator
  42. Can I redeclare let and const variables
  43. What are default values in destructuring assignment
  44. How do you swap variables in destructuring assignment
  45. What is the purpose of double tilde operator
  46. What are the list of cases error thrown from non-strict mode to strict mode
  47. What is the output of below console statement with unary operator
  48. What is the output of prepend additive operator on falsy values
  49. How do you round numbers to certain decimals
  50. What is the shortcut to get timestamp
  51. How do you use javascript libraries in typescript file
  52. How do you detect primitive or non primitive value type
  53. What is the difference between isNaN and Number.isNaN?
  54. What is nullish coalescing operator (??)?
  55. What are the differences between primitives and non-primitives?
  56. What is BigInt and how is it different from Number?
  57. What are logical assignment operators?
  58. What is the Temporal API and why is it proposed as a replacement for Date?
  59. How does JavaScript handle floating point precision issues?

Functions, scope and closures (64)

  1. What is the Difference Between call, apply, and bind
  2. What are lambda expressions or arrow functions
  3. What is a first class function
  4. What is a first order function
  5. What is a higher order function
  6. What is a unary function
  7. What is the currying function
  8. What is a pure function
  9. What are the benefits of pure functions
  10. What is an IIFE (Immediately Invoked Function Expression)
  11. What is memoization
  12. What is Hoisting
  13. What are closures
  14. What is scope in javascript
  15. What is eval
  16. What are global variables
  17. What are the problems with global variables
  18. What is the purpose of isFinite function
  19. What is an arguments object
  20. Can we define properties for functions
  21. What is the way to find the number of parameters expected by a function
  22. Is it recommended to use eval
  23. Can you apply chaining on conditional operator
  24. What is a rest parameter
  25. What happens if you do not use rest parameter as a last argument
  26. What is the purpose of uneval
  27. What is the difference between uneval and eval
  28. What is an anonymous function
  29. What is the precedence order between local and global variables
  30. What are the function parameter rules
  31. What is the call stack
  32. What is a decorator
  33. What is the purpose of compareFunction while sorting arrays
  34. How do you find the min and max values without Math functions
  35. How do you call the constructor of a parent class
  36. Why do we call javascript as dynamic language
  37. What are default parameters
  38. What is the purpose of EvalError object
  39. What is the difference between a parameter and an argument
  40. What is the output of below function calls
  41. How do you verify that an argument is a Number or not
  42. What is the difference between Function constructor and function declaration
  43. What is the difference between function and class declarations
  44. What is a Proper Tail Call
  45. How to detect if a function is called as constructor
  46. What are the differences between arguments object and rest parameter
  47. What are the differences between spread operator and rest parameter
  48. How to invoke an IIFE without any extra brackets?
  49. What is global execution context?
  50. What is function execution context?
  51. How do you create your own bind method using either call or apply method?
  52. What are the differences between pure and impure functions?
  53. What are compose and pipe functions?
  54. What is Function Composition?
  55. What is the purpose of the this keyword in JavaScript?
  56. What are the uses of closures?
  57. What are the phases of execution context?
  58. What are the examples of built-in higher order functions?
  59. What are the benefits higher order functions?
  60. What is the difference between map and forEach functions?
  61. What is Lexical Scope?
  62. How to find the number of parameters expected by a function?
  63. What is module scope in JavaScript?
  64. What is tail call optimization and does JavaScript support it?

Objects, classes and prototypes (100)

  1. What are the possible ways to create objects in JavaScript
  2. What is a prototype chain
  3. What is JSON and its common operations
  4. How do you compare Object and Map
  5. What are classes in ES6
  6. What is undefined property
  7. What is NaN property
  8. What is the difference between native, host and user objects
  9. What is the difference between an attribute and a property
  10. What is JSON
  11. What are the syntax rules of JSON
  12. What is the purpose JSON stringify
  13. How do you parse JSON string
  14. Why do you need JSON
  15. How do you check if a key exists in an object
  16. How do you loop through or enumerate javascript object
  17. How do you test for an empty object
  18. How do you compare two date objects
  19. How do you add a key value pair in javascript
  20. What are the recommendations to create new object
  21. How do you define JSON arrays
  22. What is a RegExp object
  23. What is the difference between proto and prototype
  24. What is the freeze method
  25. What is the purpose of the freeze method
  26. Why do I need to use the freeze method
  27. How do you determine whether object is frozen or not
  28. How do you determine two values same or not using object
  29. What is the purpose of using object is method
  30. How do you copy properties from one object to other
  31. What are the applications of the assign method
  32. What is a proxy object
  33. What is the purpose of the seal method
  34. What are the applications of the seal method
  35. What are the differences between the freeze and seal methods
  36. How do you determine if an object is sealed or not
  37. How do you get enumerable key and value pairs
  38. What is the main difference between Object.values and Object.entries method
  39. How can you get the list of keys of any object
  40. How do you create an object with a prototype
  41. What are javascript accessors
  42. How do you define property on Object constructor
  43. What is the difference between get and defineProperty
  44. What are the advantages of Getters and Setters
  45. Can I add getters and setters using defineProperty method
  46. What are the different ways to access object properties
  47. What is an error object
  48. What are the different error names from error object
  49. What is the Intl object
  50. What are the properties of the Intl object
  51. What is an object initializer
  52. What is a constructor method
  53. What happens if you write constructor more than once in a class
  54. How do you get the prototype of an object
  55. What happens If I pass string type for getPrototype method
  56. How do you set the prototype of one object to another
  57. How do you check whether an object can be extended or not
  58. How do you prevent an object from being extend
  59. What are the different ways to make an object non-extensible
  60. How do you define multiple properties on an object
  61. What are the validity properties
  62. Give an example usage of the rangeOverflow property
  63. Are enums available in javascript
  64. What is an enum
  65. How do you list all properties of an object
  66. How do you get property descriptors of an object
  67. What are the attributes provided by a property descriptor
  68. How do you extend classes
  69. Does JavaScript support namespaces
  70. How do you declare a namespace
  71. How do you get the timezone offset of a date object
  72. What are enhanced object literals
  73. What is the purpose of Error object
  74. Do all objects have prototypes
  75. What is the difference between Shallow and Deep copy
  76. Does javascript uses mixins
  77. Mixin Example using Object composition
  78. What is the easiest way to convert an array to an object
  79. What are the placeholders from console object
  80. What is the purpose of dir method of console object
  81. What are wrapper objects
  82. How do you make an object iterable in javascript
  83. How do you define instance and non-instance properties
  84. What are the real world use cases of proxy?
  85. What are hidden classes?
  86. What is structuredClone and how is it used for deep copying objects?
  87. What is the difference between const and Object.freeze
  88. What are private class fields in JavaScript?
  89. What is the Array.prototype.at() method and why is it useful?
  90. What are Symbols and what are their use cases?
  91. What is the difference between Object.create() and Object.assign()?
  92. What is the Reflect API and when should you use it?
  93. What is the difference between Object.keys(), Object.values(), and Object.entries()?
  94. What are the differences between Map and Object for storing key-value pairs?
  95. What is the purpose of Object.getOwnPropertyDescriptors()?
  96. How do you implement a custom error class in JavaScript?
  97. What are Proxy traps and what operations can they intercept?
  98. What are the different ways to handle circular references in JSON?
  99. How do you implement a singleton pattern in JavaScript?
  100. How do you prevent prototype pollution attacks in JavaScript?

Arrays, strings and collections (60)

  1. What is the purpose of the array slice method
  2. What is the purpose of the array splice method
  3. What is the difference between slice and splice
  4. How do you check whether a string contains a substring
  5. How do you get query string values in javascript
  6. How do you make first letter of the string in an uppercase
  7. How do you check if a string starts with another string
  8. How do you trim a string in javascript
  9. How do you define multiline strings
  10. What is a Regular Expression
  11. What are the string methods that accept Regular expression
  12. What are modifiers in regular expression
  13. What are regular expression patterns
  14. How do you search a string for a pattern
  15. What is the purpose of exec method
  16. How to convert a string to title case with javascript
  17. What is a WeakSet
  18. What are the differences between WeakSet and Set
  19. List down the collection of methods available on WeakSet
  20. What is a WeakMap
  21. What are the differences between WeakMap and Map
  22. List down the collection of methods available on WeakMap
  23. How do you sort elements in an array
  24. How do you reverse an array
  25. How do you find the min and max values in an array
  26. How do you check whether or not an array includes a particular value
  27. How do you compare scalar arrays
  28. How to set the cursor to wait
  29. How do you write multi-line strings in template literals
  30. What are raw strings
  31. What are typed arrays
  32. What is collation
  33. What is the output of below spread operator array
  34. How do you convert character to ASCII code
  35. What is ArrayBuffer
  36. What is the output of below string expression
  37. What is the purpose of some method in arrays
  38. How do you combine two or more arrays
  39. How do you create specific number of copies of a string
  40. How do you return all matching strings against a regular expression
  41. How do you trim a string at the beginning or ending
  42. How to remove all line breaks from a string
  43. What happens with negating an array
  44. What happens if we add two arrays
  45. How do you create self string using special characters
  46. How do you remove falsy values from an array
  47. How do you get unique values of an array
  48. How do you map the array values without using map method
  49. How do you empty an array
  50. How do you create an array with some data
  51. How do you flattening multi dimensional arrays
  52. What is the easiest way to resize an array
  53. What is the difference between dense and sparse arrays?
  54. What are the different ways to create sparse arrays?
  55. How do you reverse an array without modifying original array?
  56. How to verify if a variable is an array?
  57. How do you create polyfills for map, filter and reduce methods?
  58. What is the difference between substring and substr methods?
  59. What are the array mutation methods?
  60. What are the differences between SharedArrayBuffer and ArrayBuffer?

Async: promises, callbacks and the event loop (50)

  1. What is a promise
  2. Why do you need a promise
  3. Explain the three states of promise
  4. What is a callback function
  5. Why do we need callbacks
  6. What is a callback hell
  7. What are the main rules of promise
  8. What is callback in callback
  9. What is promise chaining
  10. What is promise.all
  11. Does Promise.all() cancel the other Promises?
  12. What is the purpose of the race method in promise
  13. What are the pros and cons of promises over callbacks
  14. What is the use of setTimeout
  15. What is the use of setInterval
  16. Why is JavaScript treated as Single threaded
  17. What is the purpose of clearTimeout method
  18. What is the purpose of clearInterval method
  19. How do you make synchronous HTTP request
  20. How do you make asynchronous HTTP request
  21. What is an Iterator
  22. How does synchronous iteration works
  23. What is the event loop
  24. Is postMessages synchronous
  25. What is a thunk function
  26. What are asynchronous thunks
  27. What are the different ways to deal with Asynchronous Code
  28. What is minimum timeout throttling
  29. How do you implement zero timeout in modern browsers
  30. What are tasks in event loop
  31. What is microtask
  32. What are different event loops
  33. What is the purpose of queueMicrotask
  34. What are the differences between promises and observables
  35. What is a microTask queue
  36. Is Node.js completely single threaded
  37. What is an async function
  38. How do you prevent promises swallowing errors
  39. How do you check an object is a promise or not
  40. What are the different kinds of generators
  41. What is the easiest way to ignore promise errors?
  42. What is the difference between setTimeout, setImmediate and process.nextTick?
  43. How to use await outside of async function prior to ES2022?
  44. What is Promise.any and when should it be used?
  45. What is top-level await in JavaScript modules?
  46. What are generator functions and how do they work?
  47. What is the purpose of Symbol.iterator and how do you use it?
  48. What are async iterators and how are they different from regular iterators?
  49. How does Promise.allSettled() differ from Promise.all()?
  50. What is the difference between synchronous and asynchronous generators?

ES6+ syntax and modules (19)

  1. What are modules
  2. Why do you need modules
  3. What is ECMAScript
  4. How do you get the metadata of a module
  5. List down some of the features of ES6
  6. What is ES6
  7. What are template literals
  8. What are nesting templates
  9. What are tagged templates
  10. What is destructuring assignment
  11. What are dynamic imports
  12. What are the use cases for dynamic imports
  13. What are the advantages of module loaders
  14. What is destructuring aliases
  15. What is optional chaining?
  16. What is module pattern?
  17. What is globalThis, and what is the importance of it?
  18. What are tagged template literals and their practical uses?
  19. How do you implement a lazy loading pattern for modules?

Control flow and syntax (16)

  1. What are the pros and cons of for loops
  2. What are break and continue statements
  3. What are js labels
  4. Can you give an example of when you really need a semicolon
  5. What is the purpose of switch-case
  6. What are the conventions to be followed for the usage of switch case
  7. What is an empty statement and purpose of it
  8. How do you create an infinite loop
  9. Why do you need to avoid with statement
  10. What is the output of the following for loops
  11. What is for...of statement
  12. What is the easiest multi condition checking
  13. What are the differences between for...of and for...in statements
  14. Is that possible to use expressions in switch cases?
  15. Give an example of statements affected by automatic semicolon insertion?
  16. What is the difference between for loop and forEach

Browser, DOM and web APIs (94)

  1. How do you decode or encode a URL in JavaScript?
  2. What is a service worker
  3. How do you manipulate DOM using a service worker
  4. How do you reuse information across service worker restarts
  5. What is IndexedDB
  6. What is web storage
  7. What is a post message
  8. What is a Cookie
  9. Why do you need a Cookie
  10. What are the options in a cookie
  11. How do you delete a cookie
  12. What are the differences between cookie, local storage and session storage
  13. What is the main difference between localStorage and sessionStorage
  14. How do you access web storage
  15. What are the methods available on session storage
  16. What is a storage event and its event handler
  17. Why do you need web storage
  18. How do you check web storage browser support
  19. How do you check web workers browser support
  20. Give an example of a web worker
  21. What are the restrictions of web workers on DOM
  22. What are server-sent events
  23. How do you receive server-sent event notifications
  24. How do you check browser support for server-sent events
  25. What are the events available for server sent events
  26. What is the difference between window and document
  27. How do you access history in javascript
  28. How do you detect caps lock key turned on or not
  29. What is an event flow
  30. What is event capturing
  31. What is event bubbling
  32. How do you submit a form using JavaScript
  33. How do you find operating system details
  34. What is the difference between document load and DOMContentLoaded events
  35. What is same-origin policy
  36. What are events
  37. What is the use of preventDefault method
  38. What is the use of stopPropagation method
  39. What are the steps involved in return false usage
  40. What is BOM
  41. What is an event delegation
  42. What are PWAs
  43. How do you redirect new page in javascript
  44. How do you get the current url with javascript
  45. What are the various url properties of location object
  46. What is an app shell model
  47. Can you write a random integers function to print integers within a range
  48. How do you change the style of a HTML element
  49. How do you detect a mobile browser
  50. How do you detect a mobile browser without regexp
  51. How do you get the image width and height using JS
  52. What are the properties used to get size of window
  53. What are the ways to execute javascript after a page load
  54. How do you detect a browser language preference
  55. How do you detect if javascript is disabled on the page
  56. How do you encode an URL
  57. How do you decode an URL
  58. How do you print the contents of web page
  59. How do you perform language specific date and time formatting
  60. What is the event queue
  61. How do you perform form validation using javascript
  62. How do you perform form validation without javascript
  63. What are the DOM methods available for constraint validation
  64. What are the available constraint validation DOM properties
  65. How do I modify the url without reloading the page
  66. How to get the value from get parameters
  67. How do you print numbers with commas as thousand separators
  68. How do you invoke javascript code in an iframe from the parent page
  69. How do you load CSS and JS files dynamically
  70. What are the different methods to find HTML elements in DOM
  71. Does the const variable make the value immutable
  72. Is PostMessage secure
  73. What are the problems with postmessage target origin as wildcard
  74. How do you avoid receiving postMessages from attackers
  75. Can I avoid using postMessages completely
  76. How do you get the status of a checkbox
  77. What is the difference between reflow and repaint
  78. Is it possible to add CSS to console messages
  79. Is it possible to debug HTML elements in console
  80. How do you display data in a tabular format using console object
  81. How do you create copy to clipboard button
  82. How do you capture browser back button
  83. How do you disable right click in the web page
  84. What is AJAX
  85. How to cancel a fetch request
  86. What is web speech API
  87. What is an event table
  88. How do style the console output using CSS?
  89. How do you create custom HTML element?
  90. What are the event phases of a browser?
  91. Why is it important to remove event listeners after use?
  92. What is the Intl.NumberFormat API and how is it used?
  93. What are the performance implications of using try-catch in JavaScript?
  94. What is the Performance API and how is it used for measuring performance?

Errors and debugging (7)

  1. What are the tools or techniques used for debugging JavaScript code
  2. What is a debugger statement
  3. What is the purpose of breakpoints in debugging
  4. When do you get a syntax error
  5. What are the various statements in error handling
  6. What is the MEAN stack
  7. How do you group and nest console output?

Tooling, engines and the ecosystem (25)

  1. Is JavaScript a compiled or interpreted language
  2. Is there any relation between Java and JavaScript
  3. Who created javascript
  4. What is a polyfill
  5. What is tree shaking
  6. What is the need of tree shaking
  7. What is nodejs
  8. What is obfuscation in javascript
  9. Why do you need Obfuscation
  10. What is Minification
  11. What are the advantages of minification
  12. What are the differences between obfuscation and Encryption
  13. What are the common tools used for minification
  14. What is the difference between java and javascript
  15. What is jQuery
  16. What is V8 JavaScript engine
  17. What paradigm is Javascript
  18. What is the difference between internal and external javascript
  19. Is JavaScript faster than server side script
  20. What is the difference between shim and polyfill
  21. What is babel
  22. What is deno
  23. What are the possible reasons for memory leaks?
  24. What are the optimization techniques of V8 engine?
  25. What are the best practices for optimizing JavaScript bundle size?

Everything else (24)

  1. Benefits
  2. What is heap
  3. What are the common use cases of observables
  4. What is RxJS
  5. What is a Short circuit condition
  6. What is an observable
  7. What are the built-in iterables
  8. What is debouncing?
  9. What is throttling?
  10. What is an environment record?
  11. What is pass by value and pass by reference?
  12. What is referential transparency?
  13. What are the possible side-effects in javascript?
  14. What is inline caching?
  15. What are the different ways to execute external scripts?
  16. How to detect system dark mode in javascript?
  17. What is the purpose of requestAnimationFrame method?
  18. What are shadowing and illegal shadowing?
  19. What are WeakRef and FinalizationRegistry used for?
  20. How do you implement method chaining in JavaScript?
  21. How does the Intersection Observer API work?
  22. What is the AbortController API and how is it used?
  23. How does the Mutation Observer API work?
  24. What is the Atomics API and when should it be used?

How I'd use this

Doing React next? Read 446 React interview questions.

Follow @avi_vashishta29 for one practical AI dev resource a day.

← Portfolio · Blog