518 JavaScript Interview Questions to Crack Placements in 2027
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 ★
github.com/sudheerj/javascript-interview-questions
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
- Closures and hoisting. What are closures, What is hoisting and the Temporal Dead Zone. The first thing every JS round tests.
- Promises and async/await. 50 questions in the async section, starting with What is a promise.
- 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.
- 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
- Your own debounce function, then use it on a search box.
- Your own version of bind, using call or apply.
- 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)
Source: github.com/sudheerj/javascript-interview-questions
Variables, types and operators (59)
- What is the difference between == and === operators
- What is the purpose of the let keyword
- What is the difference between let and var
- What is the reason to choose the name let as a keyword
- How do you redeclare variables in a switch block without an error
- What is the Temporal Dead Zone
- What is a strict mode in javascript
- Why do you need strict mode
- How do you declare strict mode
- What is the purpose of double exclamation
- What is the purpose of the delete operator
- What is typeof operator
- What is null value
- What is the difference between null and undefined
- What is isNaN
- What are the differences between undeclared and undefined variables
- What is the purpose of void 0
- Is JavaScript a case-sensitive language
- How do you validate an email in javascript
- How do you display the current date in javascript
- Is the !-- notation represents a special operator
- How do you assign default values to variables
- What are the benefits of keeping declarations at the top
- What are the benefits of initializing variables
- How do you generate random integers
- What would be the result of 1+2+'3'
- Can I use reserved words as identifiers
- How do you convert date to another timezone in javascript
- What is a conditional operator in javascript
- What are various operators supported by javascript
- What are the bitwise operators available in javascript
- What is a spread operator
- What are primitive data types
- What are the two types of loops in javascript
- What is an Unary operator
- What is the comma operator
- What is the advantage of the comma operator
- What is typescript
- What are the differences between javascript and typescript
- What are the advantages of typescript over javascript
- What is a void operator
- Can I redeclare let and const variables
- What are default values in destructuring assignment
- How do you swap variables in destructuring assignment
- What is the purpose of double tilde operator
- What are the list of cases error thrown from non-strict mode to strict mode
- What is the output of below console statement with unary operator
- What is the output of prepend additive operator on falsy values
- How do you round numbers to certain decimals
- What is the shortcut to get timestamp
- How do you use javascript libraries in typescript file
- How do you detect primitive or non primitive value type
- What is the difference between isNaN and Number.isNaN?
- What is nullish coalescing operator (??)?
- What are the differences between primitives and non-primitives?
- What is BigInt and how is it different from Number?
- What are logical assignment operators?
- What is the Temporal API and why is it proposed as a replacement for Date?
- How does JavaScript handle floating point precision issues?
Functions, scope and closures (64)
- What is the Difference Between call, apply, and bind
- What are lambda expressions or arrow functions
- What is a first class function
- What is a first order function
- What is a higher order function
- What is a unary function
- What is the currying function
- What is a pure function
- What are the benefits of pure functions
- What is an IIFE (Immediately Invoked Function Expression)
- What is memoization
- What is Hoisting
- What are closures
- What is scope in javascript
- What is eval
- What are global variables
- What are the problems with global variables
- What is the purpose of isFinite function
- What is an arguments object
- Can we define properties for functions
- What is the way to find the number of parameters expected by a function
- Is it recommended to use eval
- Can you apply chaining on conditional operator
- What is a rest parameter
- What happens if you do not use rest parameter as a last argument
- What is the purpose of uneval
- What is the difference between uneval and eval
- What is an anonymous function
- What is the precedence order between local and global variables
- What are the function parameter rules
- What is the call stack
- What is a decorator
- What is the purpose of compareFunction while sorting arrays
- How do you find the min and max values without Math functions
- How do you call the constructor of a parent class
- Why do we call javascript as dynamic language
- What are default parameters
- What is the purpose of EvalError object
- What is the difference between a parameter and an argument
- What is the output of below function calls
- How do you verify that an argument is a Number or not
- What is the difference between Function constructor and function declaration
- What is the difference between function and class declarations
- What is a Proper Tail Call
- How to detect if a function is called as constructor
- What are the differences between arguments object and rest parameter
- What are the differences between spread operator and rest parameter
- How to invoke an IIFE without any extra brackets?
- What is global execution context?
- What is function execution context?
- How do you create your own bind method using either call or apply method?
- What are the differences between pure and impure functions?
- What are compose and pipe functions?
- What is Function Composition?
- What is the purpose of the this keyword in JavaScript?
- What are the uses of closures?
- What are the phases of execution context?
- What are the examples of built-in higher order functions?
- What are the benefits higher order functions?
- What is the difference between map and forEach functions?
- What is Lexical Scope?
- How to find the number of parameters expected by a function?
- What is module scope in JavaScript?
- What is tail call optimization and does JavaScript support it?
Objects, classes and prototypes (100)
- What are the possible ways to create objects in JavaScript
- What is a prototype chain
- What is JSON and its common operations
- How do you compare Object and Map
- What are classes in ES6
- What is undefined property
- What is NaN property
- What is the difference between native, host and user objects
- What is the difference between an attribute and a property
- What is JSON
- What are the syntax rules of JSON
- What is the purpose JSON stringify
- How do you parse JSON string
- Why do you need JSON
- How do you check if a key exists in an object
- How do you loop through or enumerate javascript object
- How do you test for an empty object
- How do you compare two date objects
- How do you add a key value pair in javascript
- What are the recommendations to create new object
- How do you define JSON arrays
- What is a RegExp object
- What is the difference between proto and prototype
- What is the freeze method
- What is the purpose of the freeze method
- Why do I need to use the freeze method
- How do you determine whether object is frozen or not
- How do you determine two values same or not using object
- What is the purpose of using object is method
- How do you copy properties from one object to other
- What are the applications of the assign method
- What is a proxy object
- What is the purpose of the seal method
- What are the applications of the seal method
- What are the differences between the freeze and seal methods
- How do you determine if an object is sealed or not
- How do you get enumerable key and value pairs
- What is the main difference between Object.values and Object.entries method
- How can you get the list of keys of any object
- How do you create an object with a prototype
- What are javascript accessors
- How do you define property on Object constructor
- What is the difference between get and defineProperty
- What are the advantages of Getters and Setters
- Can I add getters and setters using defineProperty method
- What are the different ways to access object properties
- What is an error object
- What are the different error names from error object
- What is the Intl object
- What are the properties of the Intl object
- What is an object initializer
- What is a constructor method
- What happens if you write constructor more than once in a class
- How do you get the prototype of an object
- What happens If I pass string type for getPrototype method
- How do you set the prototype of one object to another
- How do you check whether an object can be extended or not
- How do you prevent an object from being extend
- What are the different ways to make an object non-extensible
- How do you define multiple properties on an object
- What are the validity properties
- Give an example usage of the rangeOverflow property
- Are enums available in javascript
- What is an enum
- How do you list all properties of an object
- How do you get property descriptors of an object
- What are the attributes provided by a property descriptor
- How do you extend classes
- Does JavaScript support namespaces
- How do you declare a namespace
- How do you get the timezone offset of a date object
- What are enhanced object literals
- What is the purpose of Error object
- Do all objects have prototypes
- What is the difference between Shallow and Deep copy
- Does javascript uses mixins
- Mixin Example using Object composition
- What is the easiest way to convert an array to an object
- What are the placeholders from console object
- What is the purpose of dir method of console object
- What are wrapper objects
- How do you make an object iterable in javascript
- How do you define instance and non-instance properties
- What are the real world use cases of proxy?
- What are hidden classes?
- What is structuredClone and how is it used for deep copying objects?
- What is the difference between const and Object.freeze
- What are private class fields in JavaScript?
- What is the Array.prototype.at() method and why is it useful?
- What are Symbols and what are their use cases?
- What is the difference between Object.create() and Object.assign()?
- What is the Reflect API and when should you use it?
- What is the difference between Object.keys(), Object.values(), and Object.entries()?
- What are the differences between Map and Object for storing key-value pairs?
- What is the purpose of Object.getOwnPropertyDescriptors()?
- How do you implement a custom error class in JavaScript?
- What are Proxy traps and what operations can they intercept?
- What are the different ways to handle circular references in JSON?
- How do you implement a singleton pattern in JavaScript?
- How do you prevent prototype pollution attacks in JavaScript?
Arrays, strings and collections (60)
- What is the purpose of the array slice method
- What is the purpose of the array splice method
- What is the difference between slice and splice
- How do you check whether a string contains a substring
- How do you get query string values in javascript
- How do you make first letter of the string in an uppercase
- How do you check if a string starts with another string
- How do you trim a string in javascript
- How do you define multiline strings
- What is a Regular Expression
- What are the string methods that accept Regular expression
- What are modifiers in regular expression
- What are regular expression patterns
- How do you search a string for a pattern
- What is the purpose of exec method
- How to convert a string to title case with javascript
- What is a WeakSet
- What are the differences between WeakSet and Set
- List down the collection of methods available on WeakSet
- What is a WeakMap
- What are the differences between WeakMap and Map
- List down the collection of methods available on WeakMap
- How do you sort elements in an array
- How do you reverse an array
- How do you find the min and max values in an array
- How do you check whether or not an array includes a particular value
- How do you compare scalar arrays
- How to set the cursor to wait
- How do you write multi-line strings in template literals
- What are raw strings
- What are typed arrays
- What is collation
- What is the output of below spread operator array
- How do you convert character to ASCII code
- What is ArrayBuffer
- What is the output of below string expression
- What is the purpose of some method in arrays
- How do you combine two or more arrays
- How do you create specific number of copies of a string
- How do you return all matching strings against a regular expression
- How do you trim a string at the beginning or ending
- How to remove all line breaks from a string
- What happens with negating an array
- What happens if we add two arrays
- How do you create self string using special characters
- How do you remove falsy values from an array
- How do you get unique values of an array
- How do you map the array values without using map method
- How do you empty an array
- How do you create an array with some data
- How do you flattening multi dimensional arrays
- What is the easiest way to resize an array
- What is the difference between dense and sparse arrays?
- What are the different ways to create sparse arrays?
- How do you reverse an array without modifying original array?
- How to verify if a variable is an array?
- How do you create polyfills for map, filter and reduce methods?
- What is the difference between substring and substr methods?
- What are the array mutation methods?
- What are the differences between SharedArrayBuffer and ArrayBuffer?
Async: promises, callbacks and the event loop (50)
- What is a promise
- Why do you need a promise
- Explain the three states of promise
- What is a callback function
- Why do we need callbacks
- What is a callback hell
- What are the main rules of promise
- What is callback in callback
- What is promise chaining
- What is promise.all
- Does Promise.all() cancel the other Promises?
- What is the purpose of the race method in promise
- What are the pros and cons of promises over callbacks
- What is the use of setTimeout
- What is the use of setInterval
- Why is JavaScript treated as Single threaded
- What is the purpose of clearTimeout method
- What is the purpose of clearInterval method
- How do you make synchronous HTTP request
- How do you make asynchronous HTTP request
- What is an Iterator
- How does synchronous iteration works
- What is the event loop
- Is postMessages synchronous
- What is a thunk function
- What are asynchronous thunks
- What are the different ways to deal with Asynchronous Code
- What is minimum timeout throttling
- How do you implement zero timeout in modern browsers
- What are tasks in event loop
- What is microtask
- What are different event loops
- What is the purpose of queueMicrotask
- What are the differences between promises and observables
- What is a microTask queue
- Is Node.js completely single threaded
- What is an async function
- How do you prevent promises swallowing errors
- How do you check an object is a promise or not
- What are the different kinds of generators
- What is the easiest way to ignore promise errors?
- What is the difference between setTimeout, setImmediate and process.nextTick?
- How to use await outside of async function prior to ES2022?
- What is Promise.any and when should it be used?
- What is top-level await in JavaScript modules?
- What are generator functions and how do they work?
- What is the purpose of Symbol.iterator and how do you use it?
- What are async iterators and how are they different from regular iterators?
- How does Promise.allSettled() differ from Promise.all()?
- What is the difference between synchronous and asynchronous generators?
ES6+ syntax and modules (19)
- What are modules
- Why do you need modules
- What is ECMAScript
- How do you get the metadata of a module
- List down some of the features of ES6
- What is ES6
- What are template literals
- What are nesting templates
- What are tagged templates
- What is destructuring assignment
- What are dynamic imports
- What are the use cases for dynamic imports
- What are the advantages of module loaders
- What is destructuring aliases
- What is optional chaining?
- What is module pattern?
- What is globalThis, and what is the importance of it?
- What are tagged template literals and their practical uses?
- How do you implement a lazy loading pattern for modules?
Control flow and syntax (16)
- What are the pros and cons of for loops
- What are break and continue statements
- What are js labels
- Can you give an example of when you really need a semicolon
- What is the purpose of switch-case
- What are the conventions to be followed for the usage of switch case
- What is an empty statement and purpose of it
- How do you create an infinite loop
- Why do you need to avoid with statement
- What is the output of the following for loops
- What is for...of statement
- What is the easiest multi condition checking
- What are the differences between for...of and for...in statements
- Is that possible to use expressions in switch cases?
- Give an example of statements affected by automatic semicolon insertion?
- What is the difference between for loop and forEach
Browser, DOM and web APIs (94)
- How do you decode or encode a URL in JavaScript?
- What is a service worker
- How do you manipulate DOM using a service worker
- How do you reuse information across service worker restarts
- What is IndexedDB
- What is web storage
- What is a post message
- What is a Cookie
- Why do you need a Cookie
- What are the options in a cookie
- How do you delete a cookie
- What are the differences between cookie, local storage and session storage
- What is the main difference between localStorage and sessionStorage
- How do you access web storage
- What are the methods available on session storage
- What is a storage event and its event handler
- Why do you need web storage
- How do you check web storage browser support
- How do you check web workers browser support
- Give an example of a web worker
- What are the restrictions of web workers on DOM
- What are server-sent events
- How do you receive server-sent event notifications
- How do you check browser support for server-sent events
- What are the events available for server sent events
- What is the difference between window and document
- How do you access history in javascript
- How do you detect caps lock key turned on or not
- What is an event flow
- What is event capturing
- What is event bubbling
- How do you submit a form using JavaScript
- How do you find operating system details
- What is the difference between document load and DOMContentLoaded events
- What is same-origin policy
- What are events
- What is the use of preventDefault method
- What is the use of stopPropagation method
- What are the steps involved in return false usage
- What is BOM
- What is an event delegation
- What are PWAs
- How do you redirect new page in javascript
- How do you get the current url with javascript
- What are the various url properties of location object
- What is an app shell model
- Can you write a random integers function to print integers within a range
- How do you change the style of a HTML element
- How do you detect a mobile browser
- How do you detect a mobile browser without regexp
- How do you get the image width and height using JS
- What are the properties used to get size of window
- What are the ways to execute javascript after a page load
- How do you detect a browser language preference
- How do you detect if javascript is disabled on the page
- How do you encode an URL
- How do you decode an URL
- How do you print the contents of web page
- How do you perform language specific date and time formatting
- What is the event queue
- How do you perform form validation using javascript
- How do you perform form validation without javascript
- What are the DOM methods available for constraint validation
- What are the available constraint validation DOM properties
- How do I modify the url without reloading the page
- How to get the value from get parameters
- How do you print numbers with commas as thousand separators
- How do you invoke javascript code in an iframe from the parent page
- How do you load CSS and JS files dynamically
- What are the different methods to find HTML elements in DOM
- Does the const variable make the value immutable
- Is PostMessage secure
- What are the problems with postmessage target origin as wildcard
- How do you avoid receiving postMessages from attackers
- Can I avoid using postMessages completely
- How do you get the status of a checkbox
- What is the difference between reflow and repaint
- Is it possible to add CSS to console messages
- Is it possible to debug HTML elements in console
- How do you display data in a tabular format using console object
- How do you create copy to clipboard button
- How do you capture browser back button
- How do you disable right click in the web page
- What is AJAX
- How to cancel a fetch request
- What is web speech API
- What is an event table
- How do style the console output using CSS?
- How do you create custom HTML element?
- What are the event phases of a browser?
- Why is it important to remove event listeners after use?
- What is the Intl.NumberFormat API and how is it used?
- What are the performance implications of using try-catch in JavaScript?
- What is the Performance API and how is it used for measuring performance?
Errors and debugging (7)
- What are the tools or techniques used for debugging JavaScript code
- What is a debugger statement
- What is the purpose of breakpoints in debugging
- When do you get a syntax error
- What are the various statements in error handling
- What is the MEAN stack
- How do you group and nest console output?
Tooling, engines and the ecosystem (25)
- Is JavaScript a compiled or interpreted language
- Is there any relation between Java and JavaScript
- Who created javascript
- What is a polyfill
- What is tree shaking
- What is the need of tree shaking
- What is nodejs
- What is obfuscation in javascript
- Why do you need Obfuscation
- What is Minification
- What are the advantages of minification
- What are the differences between obfuscation and Encryption
- What are the common tools used for minification
- What is the difference between java and javascript
- What is jQuery
- What is V8 JavaScript engine
- What paradigm is Javascript
- What is the difference between internal and external javascript
- Is JavaScript faster than server side script
- What is the difference between shim and polyfill
- What is babel
- What is deno
- What are the possible reasons for memory leaks?
- What are the optimization techniques of V8 engine?
- What are the best practices for optimizing JavaScript bundle size?
Everything else (24)
- Benefits
- What is heap
- What are the common use cases of observables
- What is RxJS
- What is a Short circuit condition
- What is an observable
- What are the built-in iterables
- What is debouncing?
- What is throttling?
- What is an environment record?
- What is pass by value and pass by reference?
- What is referential transparency?
- What are the possible side-effects in javascript?
- What is inline caching?
- What are the different ways to execute external scripts?
- How to detect system dark mode in javascript?
- What is the purpose of requestAnimationFrame method?
- What are shadowing and illegal shadowing?
- What are WeakRef and FinalizationRegistry used for?
- How do you implement method chaining in JavaScript?
- How does the Intersection Observer API work?
- What is the AbortController API and how is it used?
- How does the Mutation Observer API work?
- What is the Atomics API and when should it be used?
How I'd use this
- Answer each question out loud before you open the answer. Interviews test explaining, not recognising.
- For every output question you get wrong, write a two-line note on why. That list becomes your revision sheet.
- Do JavaScript before React. Most React bugs in interviews are really closure or async bugs.
- Build the 3 things above, push them to GitHub, and put the link on your resume.
Doing React next? Read 446 React interview questions.
Follow @avi_vashishta29 for one practical AI dev resource a day.