JavaScript Interview Questions for Freshers in India (2026): Top 30 with Answers
JavaScript is now the most in-demand skill for web and full-stack roles in India. Whether you are applying to a product startup, a service company, or a large tech firm, there is a near-certain chance the technical round will include JavaScript questions — even if you wrote it only in one semester project.
This guide covers the 30 questions that come up most often in fresher technical interviews, grouped by concept, with concise answers you can actually use.
Core Language Fundamentals
1. What is the difference between var, let, and const?
varis function-scoped and hoisted to the top of its function. It can be re-declared.letis block-scoped, hoisted but not initialised, and cannot be re-declared in the same scope.constis block-scoped, must be initialised at declaration, and its binding cannot be reassigned (but object properties can still be mutated).
Interview tip: Lead with "var has function scope, let and const have block scope" and you've already answered the key distinction.
2. What is hoisting?
JavaScript moves variable and function declarations to the top of their scope before code runs. var declarations are hoisted and initialised to undefined. Function declarations are hoisted completely. let and const are hoisted but remain in a "temporal dead zone" until the declaration line is reached.
3. What is the difference between == and ===?
== checks for equality after type coercion. === checks for both value and type without coercion.
0 == "0" // true (coercion)
0 === "0" // false (different types)
Always use === in production code. Interviewers may ask you to predict the result of == comparisons — just trace the coercion rules.
4. What are truthy and falsy values in JavaScript?
Falsy values: false, 0, "" (empty string), null, undefined, NaN. Everything else is truthy, including "0", [], and {}.
5. What is the difference between null and undefined?
undefinedmeans a variable has been declared but not assigned.nullis an explicit assignment indicating "no value". It is set intentionally.
Functions and Scope
6. What is a closure?
A closure is a function that retains access to variables from its outer scope even after that outer function has returned.
function counter() {
let count = 0;
return function () {
count++;
return count;
};
}
const increment = counter();
increment(); // 1
increment(); // 2
Closures are used for data privacy, factory functions, and event handlers.
7. What is the difference between a function declaration and a function expression?
A function declaration (function foo() {}) is hoisted fully. A function expression (const foo = function() {}) is hoisted as a variable but not initialised until runtime — calling it before the declaration throws a TypeError.
8. What is an arrow function? How is it different from a regular function?
Arrow functions have a shorter syntax and do not bind their own this. They inherit this from the surrounding lexical scope. They also cannot be used as constructors.
9. Explain this in JavaScript.
this depends on how a function is called:
- In the global scope (non-strict):
thisis the global object (windowin browsers). - Inside a method:
thisis the object the method belongs to. - In a constructor:
thisis the new object being created. - In an arrow function:
thisis inherited from the enclosing scope.
10. What is call, apply, and bind?
All three allow you to set this explicitly:
call(thisArg, arg1, arg2)— invokes the function immediately with individual args.apply(thisArg, [args])— same, but args as an array.bind(thisArg)— returns a new function withthispermanently bound; does not call it immediately.
Arrays and Objects
11. What is the difference between map, filter, and reduce?
maptransforms each element and returns a new array of the same length.filterreturns a new array containing only elements that pass a test.reduceaccumulates elements into a single output value.
12. What is the spread operator and how do you use it?
The spread operator (...) expands an iterable (array, string, object) into individual elements.
const a = [1, 2];
const b = [...a, 3, 4]; // [1, 2, 3, 4]
const obj1 = { x: 1 };
const obj2 = { ...obj1, y: 2 }; // { x: 1, y: 2 }
13. What is destructuring?
A syntax to unpack values from arrays or properties from objects into distinct variables.
const [first, second] = [10, 20];
const { name, age } = { name: "Riya", age: 22 };
14. What are the differences between arrays and objects in JavaScript?
Arrays are ordered lists with numeric indices. Objects are unordered key-value pairs. Both are technically objects, but arrays have special properties like .length and built-in methods for iteration.
Asynchronous JavaScript
15. What is the event loop?
JavaScript is single-threaded. The event loop continuously checks if the call stack is empty and, if so, moves tasks from the callback queue (for timers, I/O) or the microtask queue (for Promises) into the stack to be executed.
16. What is a Promise?
A Promise represents a value that may be available now, later, or never. It has three states: pending, fulfilled, and rejected. You handle results with .then() and .catch().
17. What is async/await?
async/await is syntactic sugar over Promises that makes asynchronous code read like synchronous code.
async function fetchData() {
try {
const response = await fetch("/api/data");
const data = await response.json();
return data;
} catch (err) {
console.error(err);
}
}
18. What is the difference between setTimeout and setInterval?
setTimeout(fn, delay)runsfnonce afterdelaymilliseconds.setInterval(fn, delay)runsfnrepeatedly everydelaymilliseconds until cleared.
Prototypes and Classes
19. What is prototypal inheritance?
In JavaScript, objects can inherit properties and methods from other objects through a prototype chain. When you access a property on an object, the engine first looks on the object itself, then on its prototype, then on the prototype's prototype, and so on.
20. What is the difference between a class and a prototype in JavaScript?
ES6 classes are syntactic sugar over the prototype-based system. Under the hood, a class still uses prototypes; the class keyword just makes the syntax cleaner and closer to other OOP languages.
21. What is Object.create()?
Object.create(proto) creates a new object whose prototype is set to proto. It's a direct way to set up prototypal inheritance without using a constructor function.
DOM and Browser Concepts
22. What is the difference between getElementById and querySelector?
getElementById("id")returns a single element by ID (fast, ID-specific).querySelector(".class")returns the first element matching any CSS selector.querySelectorAll(".class")returns a NodeList of all matches.
23. What is event delegation?
Instead of attaching event listeners to every child element, you attach one listener to a parent. Because events bubble up the DOM, the parent catches events from all its children. This is efficient for dynamic lists.
24. What is the difference between event.preventDefault() and event.stopPropagation()?
preventDefault()stops the browser's default action (e.g., form submission, link navigation).stopPropagation()stops the event from bubbling up to parent elements.
Common Gotchas (Frequently Asked)
25. What will this output?
console.log(typeof null); // "object"
A known bug in JavaScript that was never fixed for backwards compatibility. typeof null returns "object", not "null".
26. What is NaN and how do you check for it?
NaN (Not a Number) is the result of invalid numeric operations. Counterintuitively, NaN !== NaN is true. Use Number.isNaN(value) to check for it reliably.
27. What is the difference between deep copy and shallow copy?
A shallow copy copies only the top-level properties; nested objects are still shared by reference. A deep copy creates completely independent copies of all nested values. Object.assign() and the spread operator produce shallow copies. structuredClone() (modern) or JSON.parse(JSON.stringify(obj)) produce deep copies.
28. What is a higher-order function?
A function that either takes one or more functions as arguments or returns a function. map, filter, and reduce are examples of higher-order functions.
29. What is memoisation?
An optimisation technique that caches the results of expensive function calls and returns the cached result when the same inputs are given again.
30. What is the difference between localStorage and sessionStorage?
Both store key-value pairs in the browser, but localStorage persists until explicitly cleared, while sessionStorage is cleared when the tab or browser session ends.
How to Use This in Your Preparation
Interviewers rarely ask all 30. They pick 5–8 questions and go deep. The pattern at most service companies (TCS, Infosys, Cognizant, Accenture): 2–3 fundamentals, 1–2 on async, 1–2 coding questions. At product companies and startups: more depth on closures, the event loop, and live coding.
Knowing the definition is the floor. Knowing the "why" — why closures matter, why
===beats==, whyvarscoping breaks things — is what moves you from a 6 to a 9.
For each concept above, open the browser console, type three variations, and see what happens. Reading about closures takes 10 minutes. Writing a counter function that uses one takes 5 minutes and teaches you more.
If you want to practice explaining these concepts under interview conditions and get scored feedback on your answers, see CareerClutch's features.