Core JavaScript Master: Prototypes, Closures, Event Loop, ES6+ & Web APIs
The definitive 521 JavaScript interview questions covering Object prototypes, closures, event loop, Promises, ES6-ES2024, Web APIs, DOM, and performance.
Curriculum Roadmap & Learning Path
8 StagesPart 1: Core Objects, Prototypes, Functions & Scope (1 - 53)
53 QuestionsWhat is JavaScript, and what are its core architectural characteristics?
What are the primitive and reference data types in JavaScript, and how are they stored in memory?
What is the difference between JavaScript and ECMAScript?
What are the possible ways to create objects in JavaScript
What is a prototype chain
What is the Difference Between call, apply, and bind
What is JSON and its common operations
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 compare Object and Map
What is the difference between == and === operators
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 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 an IIFE (Immediately Invoked Function Expression)
How do you decode or encode a URL in JavaScript?
What is memoization
What is Hoisting
What are classes in ES6
What are closures
What are modules
Why do you need modules
What is scope 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
Part 2: Promises, Callbacks, Async & Strict Mode (54 - 103)
50 QuestionsWhat are the restrictions of web workers on DOM
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 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 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 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 undefined property
What is null value
What is the difference between null and undefined
What is eval
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 isNaN
What are the differences between undeclared and undefined variables
What are global variables
What are the problems with global variables
What is NaN property
What is the purpose of isFinite function
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 the difference between native, host and user objects
What are the tools or techniques used for debugging JavaScript code
What are the pros and cons of promises over callbacks
What is the difference between an attribute and a property
What is same-origin policy
What is the purpose of void 0
Is JavaScript a compiled or interpreted language
Is JavaScript a case-sensitive language
Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)
70 QuestionsIs there any relation between Java and JavaScript
What are events
Who created javascript
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 the use of setTimeout
What is the use of setInterval
Why is JavaScript treated as Single threaded
What is an event delegation
What is ECMAScript
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
What are PWAs
What is the purpose of clearTimeout method
What is the purpose of clearInterval method
How do you redirect new page in javascript
How do you check whether a string contains a substring
How do you validate an email in javascript
How do you get the current url with javascript
What are the various url properties of location object
How do you get query string values in javascript
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
What is an arguments object
How do you make first letter of the string in an uppercase
What are the pros and cons of for loops
How do you display the current date in javascript
How do you compare two date objects
How do you check if a string starts with another string
How do you trim a string in javascript
How do you add a key value pair in javascript
Is the !-- notation represents a special operator
How do you assign default values to variables
How do you define multiline strings
What is an app shell model
Can we define properties for functions
What is the way to find the number of parameters expected by a function
What is a polyfill
What are break and continue statements
What are js labels
What are the benefits of keeping declarations at the top
What are the benefits of initializing variables
What are the recommendations to create new object
How do you define JSON arrays
How do you generate random integers
Can you write a random integers function to print integers within a range
What is tree shaking
What is the need of tree shaking
Is it recommended to use eval
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
What is a RegExp object
How do you search a string for a pattern
What is the purpose of exec method
How do you change the style of a HTML element
What would be the result of 1+2+'3'
What is a debugger statement
What is the purpose of breakpoints in debugging
Can I use reserved words as identifiers
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
Part 4: Prototypes, Object Methods & Event Loop (174 - 253)
80 QuestionsHow do you make synchronous HTTP request
How do you make asynchronous HTTP request
How do you convert date to another timezone in javascript
What are the properties used to get size of window
What is a conditional operator in javascript
Can you apply chaining on conditional operator
What are the ways to execute javascript after a page load
What is the difference between proto and prototype
Can you give an example of when you really need a semicolon
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 detect a browser language preference
How to convert a string to title case with javascript
How do you detect if javascript is disabled on the page
What are various operators supported by javascript
What is a rest parameter
What happens if you do not use rest parameter as a last argument
What are the bitwise operators available in javascript
What is a spread operator
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 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
What is the purpose of uneval
How do you encode an URL
How do you decode an URL
How do you print the contents of web page
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 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 is the purpose of switch-case
What are the conventions to be followed for the usage of switch case
What are primitive data types
What are the different ways to access object properties
What are the function parameter rules
What is an error object
When do you get a syntax error
What are the different error names from error object
What are the various statements in error handling
What are the two types of loops in javascript
What is nodejs
What is the Intl object
How do you perform language specific date and time formatting
What is an Iterator
How does synchronous iteration works
What is the event loop
What is the call stack
What is the event queue
What is a decorator
What are the properties of the Intl object
What is an Unary operator
How do you sort elements in an array
What is the purpose of compareFunction while sorting arrays
How do you reverse an array
How do you find the min and max values in an array
How do you find the min and max values without Math functions
What is an empty statement and purpose of it
How do you get the metadata of a module
Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)
75 QuestionsWhat 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 an object initializer
What is a constructor method
What happens if you write constructor more than once in a class
How do you call the constructor of a parent 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 is the MEAN stack
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
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
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
How do I modify the url without reloading the page
How do you check whether or not an array includes a particular value
How do you compare scalar arrays
How to get the value from get parameters
How do you print numbers with commas as thousand separators
What is the difference between java and javascript
Does JavaScript support namespaces
How do you declare a namespace
How do you invoke javascript code in an iframe from the parent page
How do you get the timezone offset of a date object
How do you load CSS and JS files dynamically
What are the different methods to find HTML elements in DOM
What is jQuery
What is V8 JavaScript engine
Why do we call javascript as dynamic language
What is a void operator
How to set the cursor to wait
How do you create an infinite loop
Why do you need to avoid with statement
What is the output of the following for loops
List down some of the features of ES6
What is ES6
Can I redeclare let and const variables
Does the const variable make the value immutable
What are default parameters
What are template literals
How do you write multi-line strings in template literals
What are nesting templates
What are tagged templates
What are raw strings
What is destructuring assignment
What are default values in destructuring assignment
How do you swap variables in destructuring assignment
What are enhanced object literals
What are dynamic imports
What are the use cases for dynamic imports
What are typed arrays
What are the advantages of module loaders
What is collation
What is for...of statement
Part 6: Async Internals, Memory, Microtasks & Web APIs (329 - 403)
75 QuestionsWhat is the output of below spread operator array
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
Is postMessages synchronous
What paradigm is Javascript
What is the difference between internal and external javascript
Is JavaScript faster than server side script
How do you get the status of a checkbox
What is the purpose of double tilde operator
How do you convert character to ASCII code
What is ArrayBuffer
What is the output of below string expression
What is the purpose of Error object
What is the purpose of EvalError object
What are the list of cases error thrown from non-strict mode to strict mode
Do all objects have prototypes
What is the difference between a parameter and an argument
What is the purpose of some method in arrays
How do you combine two or more arrays
What is the difference between Shallow and Deep copy
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
What is the output of below console statement with unary operator
Does javascript uses mixins
Mixin Example using Object composition
Benefits
What is a thunk function
What are asynchronous thunks
What is the output of below function calls
How to remove all line breaks from a string
What is the difference between reflow and repaint
What happens with negating an array
What happens if we add two arrays
What is the output of prepend additive operator on falsy values
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
What is destructuring aliases
How do you map the array values without using map method
How do you empty an array
How do you round numbers to certain decimals
What is the easiest way to convert an array to an object
How do you create an array with some data
What are the placeholders from console object
Is it possible to add CSS to console messages
What is the purpose of dir method of console object
Is it possible to debug HTML elements in console
How do you display data in a tabular format using console object
How do you verify that an argument is a Number or not
How do you create copy to clipboard button
What is the shortcut to get timestamp
How do you flattening multi dimensional arrays
What is the easiest multi condition checking
How do you capture browser back button
How do you disable right click in the web page
What are wrapper objects
What is AJAX
What are the different ways to deal with Asynchronous Code
How to cancel a fetch request
What is web speech API
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
How do you use javascript libraries in typescript file
What are the differences between promises and observables
What is heap
What is an event table
What is a microTask queue
What is the difference between shim and polyfill
Part 7: Execution Context, Functional JS & V8 Engine (404 - 463)
60 QuestionsHow do you detect primitive or non primitive value type
What is babel
Is Node.js completely single threaded
What are the common use cases of observables
What is RxJS
What is the difference between Function constructor and function declaration
What is a Short circuit condition
What is the easiest way to resize an array
What is an observable
What is the difference between function and class declarations
What is an async function
How do you prevent promises swallowing errors
What is deno
How do you make an object iterable in javascript
What is a Proper Tail Call
How do you check an object is a promise or not
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
What are the different kinds of generators
What are the built-in iterables
What are the differences between for...of and for...in statements
How do you define instance and non-instance properties
What is the difference between isNaN and Number.isNaN?
How to invoke an IIFE without any extra brackets?
Is that possible to use expressions in switch cases?
What is the easiest way to ignore promise errors?
How do style the console output using CSS?
What is nullish coalescing operator (??)?
How do you group and nest console output?
What is the difference between dense and sparse arrays?
What are the different ways to create sparse arrays?
What is the difference between setTimeout, setImmediate and process.nextTick?
How do you reverse an array without modifying original array?
How do you create custom HTML element?
What is global execution context?
What is function execution context?
What is debouncing?
What is throttling?
What is optional chaining?
What is an environment record?
How to verify if a variable is an array?
What is pass by value and pass by reference?
What are the differences between primitives and non-primitives?
How do you create your own bind method using either call or apply method?
What are the differences between pure and impure functions?
What is referential transparency?
What are the possible side-effects in javascript?
What are compose and pipe functions?
What is module pattern?
What is Function Composition?
How to use await outside of async function prior to ES2022?
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 possible reasons for memory leaks?
What are the optimization techniques of V8 engine?
What are the examples of built-in higher order functions?
What are the benefits higher order functions?
How do you create polyfills for map, filter and reduce methods?
Part 8: Modern JavaScript APIs, WeakRef, Proxy & Performance (464 - 521)
58 QuestionsWhat is the difference between map and forEach functions?
Give an example of statements affected by automatic semicolon insertion?
What are the event phases of a browser?
What are the real world use cases of proxy?
What are hidden classes?
What is inline caching?
What are the different ways to execute external scripts?
What is Lexical Scope?
How to detect system dark mode in javascript?
What is the purpose of requestAnimationFrame method?
What is the difference between substring and substr methods?
How to find the number of parameters expected by a function?
What is globalThis, and what is the importance of it?
What are the array mutation methods?
What is module scope in JavaScript?
What are shadowing and illegal shadowing?
Why is it important to remove event listeners after use?
What is structuredClone and how is it used for deep copying objects?
What is the difference between const and Object.freeze
What is Promise.any and when should it be used?
What is BigInt and how is it different from Number?
What are private class fields in JavaScript?
What is the Array.prototype.at() method and why is it useful?
What is top-level await in JavaScript modules?
What are WeakRef and FinalizationRegistry used for?
What are logical assignment operators?
What is the Temporal API and why is it proposed as a replacement for Date?
What is the difference between for loop and forEach
What are Symbols and what are their use cases?
What is the difference between Object.create() and Object.assign()?
What are generator functions and how do they work?
What is the Reflect API and when should you use it?
How does JavaScript handle floating point precision issues?
What are tagged template literals and their practical uses?
What is the difference between Object.keys(), Object.values(), and Object.entries()?
What is the Intl.NumberFormat API and how is it used?
How do you implement method chaining in JavaScript?
What are the differences between Map and Object for storing key-value pairs?
What is the purpose of Symbol.iterator and how do you use it?
How does the Intersection Observer API work?
What are async iterators and how are they different from regular iterators?
What is the purpose of Object.getOwnPropertyDescriptors()?
How does Promise.allSettled() differ from Promise.all()?
What are the performance implications of using try-catch in JavaScript?
What is the AbortController API and how is it used?
How do you implement a custom error class in JavaScript?
What is the difference between synchronous and asynchronous generators?
What are Proxy traps and what operations can they intercept?
How does the Mutation Observer API work?
What is tail call optimization and does JavaScript support it?
What are the different ways to handle circular references in JSON?
How do you implement a singleton pattern in JavaScript?
What is the Performance API and how is it used for measuring performance?
What are the differences between SharedArrayBuffer and ArrayBuffer?
How do you prevent prototype pollution attacks in JavaScript?
What is the Atomics API and when should it be used?
How do you implement a lazy loading pattern for modules?
What are the best practices for optimizing JavaScript bundle size?