Javascript Interview Questions & Answers

Top frequently asked interview questions with detailed answers, code examples, and expert tips.

120 Questions All Difficulty Levels Updated Mar 2026
1

What is JavaScript? Easy

JavaScript is a high-level interpreted programming language used to create dynamic and interactive web applications.
basics definition
2

What are JavaScript data types? Easy

Primitive types include string, number, boolean, null, undefined, symbol, bigint. Non-primitive type is object.
datatypes
3

What is undefined? Easy

A variable declared but not assigned a value is undefined.
datatypes
4

What is null? Easy

Null represents an intentional absence of value.
datatypes
5

Difference between var, let, and const? Easy

var is function scoped. let and const are block scoped. const cannot be reassigned.
variables scope
6

What is hoisting? Easy

JavaScript moves variable and function declarations to the top of their scope during compilation.
hoisting
7

What is a closure? Easy

A closure is a function that remembers variables from its outer lexical scope.
functions closure
8

What is the DOM? Easy

DOM is the Document Object Model that represents HTML structure as objects.
dom
9

Difference between == and ===? Easy

== performs type coercion. === checks both value and type.
comparison
10

What is an array? Easy

An array is an ordered collection of values.
array
11

What is an object? Easy

An object is a collection of key-value pairs.
object
12

What is a function? Easy

A function is a reusable block of code.
function
13

What is JSON? Easy

JSON is JavaScript Object Notation used for data exchange.
json
14

What is NaN? Easy

NaN means Not a Number.
numbers
15

What is template literal? Easy

Template literals allow string interpolation using backticks.
es6
16

What is an arrow function? Easy

Arrow function is a shorter syntax for writing functions.
es6 function
17

What is this keyword? Easy

this refers to the execution context object.
this
18

What is event bubbling? Easy

Event bubbling propagates events upward in DOM tree.
dom events
19

What is event capturing? Easy

Event capturing propagates events downward in DOM tree.
dom events
20

What is localStorage? Easy

localStorage stores data permanently in browser.
storage
21

What is sessionStorage? Easy

sessionStorage stores data for current session only.
storage
22

What is type coercion? Easy

Automatic conversion of data types.
conversion
23

What is strict mode? Easy

Strict mode enforces stricter parsing and error handling.
strict
24

What is a callback function? Easy

Function passed as argument to another function.
callback
25

What is recursion? Easy

Function calling itself repeatedly.
recursion
26

What is spread operator? Easy

Spread operator expands iterable using ...
es6
27

What is destructuring? Easy

Extract values from arrays or objects.
es6
28

What is Promise? Easy

Promise represents future completion of async operation.
async
29

What is map() method? Easy

map() creates new array by transforming each element.
array
30

What is filter() method? Easy

filter() returns elements that match condition.
array
31

What is reduce()? Easy

reduce() reduces array to single value.
array
32

Difference between null and undefined? Easy

null is intentional absence; undefined means not assigned.
datatypes
33

What is typeof operator? Easy

typeof returns data type of variable.
operator
34

What is IIFE? Easy

Immediately Invoked Function Expression executes immediately.
function
35

What is event listener? Easy

Event listener waits for specific event to occur.
events
36

What is setTimeout? Easy

setTimeout executes function after delay.
async
37

What is setInterval? Easy

setInterval repeatedly executes function.
async
38

What is ES6? Easy

ES6 is ECMAScript 2015 version introducing modern features.
es6
39

What is default parameter? Easy

Default value assigned to function parameter.
function
40

What is rest parameter? Easy

Rest parameter collects multiple arguments into array.
es6
41

Explain Event Loop in detail. Medium

Event Loop continuously checks call stack and task queues to execute asynchronous tasks without blocking main thread.
event-loop async
42

What is Call Stack? Medium

Call stack is a data structure that keeps track of function execution.
execution
43

Microtasks vs Macrotasks? Medium

Microtasks (Promises) execute before macrotasks (setTimeout).
async event-loop
44

Explain lexical scope. Medium

Lexical scope means scope is determined by where variables are written in code.
scope
45

What is closure in loops issue? Medium

Using var in loops creates shared reference causing unexpected behavior.
closure scope
46

Explain prototype chain. Medium

Objects inherit properties through prototype chain lookup.
prototype
47

Difference between deep and shallow copy? Medium

Shallow copy copies references. Deep copy clones nested objects fully.
object
48

What is Object.freeze()? Medium

Prevents modification of object properties.
object
49

What is Object.seal()? Medium

Prevents adding/removing properties but allows modification.
object
50

What is currying? Medium

Transforming a function into a sequence of functions taking one argument.
functional
51

Explain bind(), call(), apply(). Medium

Used to explicitly set this context.
this
52

What is event delegation? Medium

Handling events at parent level instead of individual elements.
dom events
53

What is debouncing? Medium

Limits execution of a function until delay passes.
performance
54

What is throttling? Medium

Ensures function executes at fixed intervals.
performance
55

Explain Promise chaining. Medium

Allows sequential execution using .then().
async promise
56

What is async/await internally? Medium

Syntactic sugar over Promises.
async
57

How fetch() works? Medium

Fetch returns Promise resolving to Response object.
api
58

What is CORS? Medium

Cross-Origin Resource Sharing policy controlling resource access.
security
59

What is WeakMap? Medium

WeakMap holds weak object references allowing garbage collection.
es6
60

What is WeakSet? Medium

WeakSet stores unique objects with weak references.
es6
61

Explain Symbol data type. Medium

Symbol creates unique identifiers.
datatype
62

What is generator function? Medium

Function* that yields multiple values lazily.
es6
63

What is Map vs Object? Medium

Map maintains insertion order and allows any key type.
es6
64

Explain destructuring nested objects. Medium

Extract nested properties using pattern matching.
es6
65

What is spread vs rest? Medium

Spread expands, rest collects values.
es6
66

What is module pattern? Medium

Encapsulates private variables using closures.
patterns
67

Explain Immediately Invoked Async Function. Medium

Async IIFE executes immediately returning Promise.
async
68

Explain event bubbling vs capturing. Medium

Bubbling flows up, capturing flows down DOM tree.
dom
69

What is tree shaking? Medium

Removes unused code during bundling.
webpack
70

Explain dynamic imports. Medium

Load modules on demand using import().
modules
71

How to prevent default behavior? Medium

Use event.preventDefault().
events
72

Explain memoization. Medium

Caching function results for performance.
optimization
73

Explain tail call optimization. Medium

Optimizes recursive calls to avoid stack overflow.
recursion
74

Explain strict mode advantages. Medium

Catches silent errors and prevents unsafe actions.
strict
75

What is optional chaining? Medium

Safely access nested properties using ?.
es6
76

Explain nullish coalescing. Medium

Returns right operand if left is null or undefined.
es6
77

How does JSON.parse work? Medium

Converts JSON string into JS object.
json
78

What is error handling in async? Medium

Use try/catch with async await.
async error
79

What is service worker? Medium

Runs in background enabling offline support.
browser
80

Explain browser rendering process. Medium

HTML → DOM → CSSOM → Render Tree → Layout → Paint.
browser
81

Explain memory heap. Medium

Heap stores objects in memory.
memory
82

What is IIFE privacy pattern? Medium

Encapsulates variables avoiding global scope pollution.
pattern
83

Explain module bundlers. Medium

Tools like Webpack bundle JS modules.
tooling
84

What is event loop starvation? Medium

Long sync tasks blocking async queue.
event-loop
85

Explain structured cloning. Medium

Deep copying using structuredClone().
object
86

What is proxy trap? Medium

Intercepts object operations using Proxy.
es6
87

Explain memory leaks in closures. Medium

Unreleased references prevent GC.
memory
88

How to handle large lists efficiently? Medium

Use virtualization and pagination.
performance
89

What is browser repaint vs reflow? Medium

Reflow recalculates layout, repaint updates visuals.
performance
90

Explain WebSockets. Medium

Full duplex communication protocol over TCP.
network
91

How V8 engine works internally? Hard

V8 uses JIT compilation converting JS to machine code.
engine
92

Explain Just-In-Time compilation. Hard

Compiles code at runtime for performance.
engine
93

What is garbage collection algorithm? Hard

Mark-and-sweep algorithm cleans unused memory.
memory
94

Explain event loop phases in Node.js. Hard

Timers → Pending → Idle → Poll → Check → Close callbacks.
node event-loop
95

Implement custom Promise. Hard

Create class with then/catch methods managing state.
promise
96

Explain microtask queue priority. Hard

Microtasks run before next macrotask.
async
97

How to detect memory leak? Hard

Use Chrome DevTools heap snapshots.
memory
98

Explain Shadow DOM internals. Hard

Encapsulated DOM subtree.
dom
99

What is CSP? Hard

Content Security Policy prevents XSS attacks.
security
100

How to prevent XSS? Hard

Escape user input and use CSP.
security
101

Explain SSR vs CSR. Hard

Server-side vs client-side rendering.
architecture
102

What is WebAssembly? Hard

Binary format enabling near-native speed execution.
wasm
103

Explain concurrency model. Hard

Single-threaded with async event-driven architecture.
architecture
104

How prototype inheritance differs from classical? Hard

JS uses delegation model.
prototype
105

Explain functional programming concepts. Hard

Pure functions, immutability, higher-order functions.
functional
106

Implement debounce function manually. Hard

Use setTimeout clearing previous timer.
performance
107

Implement throttle manually. Hard

Use timestamp or flag to limit calls.
performance
108

Explain virtual DOM concept. Hard

Efficient DOM diffing before updates.
dom
109

What is event loop blocking? Hard

Long sync tasks block async tasks.
event-loop
110

Explain heap vs stack memory. Hard

Stack stores primitives, heap stores objects.
memory
111

How to optimize rendering? Hard

Minimize DOM operations and reflows.
performance
112

Explain web worker limitations. Hard

No direct DOM access.
browser
113

Explain atomic operations in JS. Hard

Used with SharedArrayBuffer.
advanced
114

What is SharedArrayBuffer? Hard

Shared memory between workers.
advanced
115

Explain streaming APIs. Hard

Process data chunk by chunk.
network
116

What is IndexedDB? Hard

Low-level API for client storage.
browser
117

Explain event delegation performance benefit. Hard

Reduces number of listeners.
performance
118

Explain lazy loading modules. Hard

Load modules only when needed.
optimization
119

Explain tree shaking in depth. Hard

Static analysis removes unused exports.
bundler
120

How to build large scale JS app? Hard

Use modular architecture, state management, code splitting.
architecture
📊 Questions Breakdown
🟢 Easy 40
🟡 Medium 50
🔴 Hard 30
🎓 Master Javascript Training

Join our live classes with expert instructors and hands-on projects.

Enroll Now

What People Say

Testimonial

Nagmani Solanki

Digital Marketing

Edugators platform is the best place to learn live classes, and live projects by which you can understand easily and have excellent customer service.

Testimonial

Saurabh Arya

Full Stack Developer

It was a very good experience. Edugators and the instructor worked with us through the whole process to ensure we received the best training solution for our needs.

testimonial

Praveen Madhukar

Web Design

I would definitely recommend taking courses from Edugators. The instructors are very knowledgeable, receptive to questions and willing to go out of the way to help you.

Need To Train Your Corporate Team ?

Customized Corporate Training Programs and Developing Skills For Project Success.

Google AdWords Training
React Training
Angular Training
Node.js Training
AWS Training
DevOps Training
Python Training
Hadoop Training
Photoshop Training
CorelDraw Training
.NET Training

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators