JavaScript Interview Questions for Freshers (2026): 35 Questions with Answers
- Home
- Blog
- Full Stack & Programming
- JavaScript Interview Questions for Freshers (2026): 35 Questions with Answers
Short answer: fresher JavaScript interviews test how the language actually works: var vs let vs const, scope and hoisting, closures, the this keyword, == vs ===, the event loop, and asynchronous code with callbacks, promises and async/await. Expect ES6 features (arrow functions, destructuring, spread/rest) and two or three short coding tasks such as reversing a string or removing duplicates. The answers below are short enough to say aloud, with code where it helps.
If you are heading into front-end roles, pair this with our React interview questions. For the full process, see the tech interview preparation guide.
Basics and types
1. What are JavaScript’s data types?
Primitives: string, number, boolean, null, undefined, bigint and symbol. Everything else is an object (including arrays and functions). Primitives are immutable and compared by value; objects are compared by reference.
2. What is the difference between null and undefined?
undefined means a variable has been declared but not assigned. null is an intentional “no value” you assign yourself. typeof undefined is “undefined”, while typeof null is “object” (a long-standing quirk).
3. What is the difference between == and ===?
== compares after type coercion, so 0 == "0" is true. === compares value and type with no coercion, so 0 === "0" is false. Prefer === to avoid surprises.
4. What are truthy and falsy values?
Falsy values are false, 0, "", null, undefined and NaN. Everything else is truthy, including "0", "false", [] and {}.
5. What is the difference between primitive and reference types?
Primitives are copied by value. Objects, arrays and functions are copied by reference, so two variables can point to the same object and changes are visible through both.
Variables, scope and hoisting
6. What is the difference between var, let and const?
| var | let | const | |
|---|---|---|---|
| Scope | Function | Block | Block |
| Re-declare | Yes | No | No |
| Re-assign | Yes | Yes | No |
| Hoisting | Hoisted, initialised undefined | Hoisted, not initialised (TDZ) | Hoisted, not initialised (TDZ) |
Use const by default, let when you must reassign, and avoid var.
7. What is hoisting?
JavaScript moves declarations to the top of their scope before running code. var and function declarations are hoisted and usable early (var as undefined); let and const are hoisted but stay in the “temporal dead zone” until the declaration line, so using them earlier throws.
8. What is scope, and what is lexical scope?
Scope is where a variable is accessible: global, function or block. Lexical scope means inner functions can access variables from the functions they are defined inside, based on where they are written, not where they are called.
9. What is a closure?
A function that remembers variables from the scope where it was created, even after that scope has returned. Closures power private variables and function factories.
function counter() {
let count = 0;
return () => ++count; // remembers count
}
const next = counter();
next(); // 1
next(); // 2
10. What is the difference between a function declaration and a function expression?
A declaration (function foo(){}) is fully hoisted and can be called before its line. An expression (const foo = function(){} or an arrow function) is only available after it is assigned.
Functions and this
11. What is the this keyword?
this refers to the object that is calling the function. In a method it is the object; alone or in a plain function it is the global object (or undefined in strict mode); with new it is the new instance. Arrow functions do not have their own this; they use the surrounding scope’s.
12. What is the difference between arrow functions and regular functions?
Arrow functions are shorter, have no own this, arguments or prototype, and cannot be used as constructors. They are ideal for callbacks where you want to keep the outer this.
13. What do call, apply and bind do?
All set this for a function. call invokes it with arguments listed individually, apply with an array of arguments, and bind returns a new function with this fixed for later use.
14. What are higher-order functions?
Functions that take other functions as arguments or return functions, such as map, filter, reduce and setTimeout.
15. What is the difference between map, filter and reduce?
map transforms each item into a new array of the same length; filter keeps items that pass a test; reduce boils an array down to a single value such as a sum or a grouped object.
Objects, arrays and ES6
16. What is destructuring?
const { name, age } = user;
const [first, second] = items;
17. What is the difference between the spread and rest operators?
Both use .... Spread expands an array or object ([...a, ...b], {...obj}); rest collects remaining items into one (function sum(...nums)).
18. How do you copy an object or array, and what is a shallow vs deep copy?
Spread or Object.assign make a shallow copy (nested objects are still shared). For a deep copy use structuredClone(obj) in modern environments, or a library for older ones.
19. What are template literals?
Backtick strings that allow interpolation and multiline text: `Hello ${name}`.
20. What is optional chaining and nullish coalescing?
a?.b?.c safely reads nested properties and returns undefined instead of throwing if something is missing. a ?? b returns b only when a is null or undefined (unlike ||, which also triggers on 0 or "").
21. What is the difference between forEach and map?
forEach runs a function for each item and returns nothing; map returns a new array. Use map when you need the transformed result.
Asynchronous JavaScript
22. Is JavaScript single-threaded?
Yes. It runs on one main thread with a call stack, and uses the event loop plus Web APIs to handle asynchronous work without blocking.
23. What is the event loop?
The mechanism that lets single-threaded JavaScript be non-blocking. When the call stack is empty, the event loop takes queued callbacks and runs them. Microtasks (promise callbacks) run before macrotasks (timers), which is why a resolved promise runs before a setTimeout(…, 0).
24. What is a callback, and what is callback hell?
A callback is a function passed to run later. Nesting many callbacks for sequential async steps becomes hard to read (“callback hell”); promises and async/await solve this.
25. What is a promise?
An object representing a future value with three states: pending, fulfilled or rejected. You handle it with .then() and .catch(), or with async/await.
fetch("/api/user")
.then(res => res.json())
.then(user => console.log(user))
.catch(err => console.error(err));
26. What is async/await?
Syntax that lets you write promise-based code as if it were synchronous. An async function returns a promise, and await pauses until a promise settles. Use try/catch for errors.
async function getUser() {
try {
const res = await fetch("/api/user");
return await res.json();
} catch (err) {
console.error(err);
}
}
27. What is the difference between Promise.all and Promise.race?
Promise.all waits for all promises and rejects if any one fails; Promise.race settles as soon as the first one settles. Promise.allSettled waits for all and reports each result.
DOM and the browser
28. What is the DOM?
The Document Object Model: a tree representation of the page that JavaScript can read and change with methods such as querySelector, addEventListener and createElement.
29. What is event bubbling and delegation?
Bubbling means an event travels from the target up through its ancestors. Event delegation uses this by putting one listener on a parent and checking event.target, which is efficient for many similar children.
30. What is the difference between localStorage, sessionStorage and cookies?
localStorage persists until cleared; sessionStorage lasts for the tab session; cookies are small, sent with requests and often used for auth. Storage holds strings, so you serialise objects with JSON.
31. What is the difference between debounce and throttle?
Debounce waits until activity stops before running (good for search-as-you-type); throttle runs at most once per interval (good for scroll handlers).
Coding tasks
32. Reverse a string.
const reverse = s => s.split("").reverse().join("");
33. Check for a palindrome.
const isPalindrome = s => {
const clean = s.toLowerCase().replace(/[^a-z0-9]/g, "");
return clean === clean.split("").reverse().join("");
};
34. Remove duplicates from an array.
const unique = arr => [...new Set(arr)];
35. Count the frequency of items.
const counts = arr => arr.reduce((acc, item) => {
acc[item] = (acc[item] || 0) + 1;
return acc;
}, {});
How to prepare
- Write every snippet above yourself and predict the output before running it.
- Practise explaining closures,
thisand the event loop aloud, with an example each. - Solve 20 to 30 small problems on strings, arrays and objects.
- Build one small project (a to-do app or a page that fetches and shows API data) and then move on to our React interview questions.
Learn JavaScript at TryCatch Classes
TryCatch Classes’ JavaScript Training covers the language from basics to advanced: the this keyword, closures and higher-order functions, asynchronous JavaScript (the event loop, promises and async/await), modern OOP and ES6 features, with live projects and interview preparation. To build interfaces next, see React JS Training. Learn at our Borivali West classroom or live online, with a 100% placement guarantee.
A note from Mehul Prajapati, Founder, TryCatch Classes
I have spent 18+ years in IT and training and have personally mentored 12,000+ students. If you are planning your next step in JavaScript and want a second opinion on your learning path, I am happy to help.
“The technology you learn today may change tomorrow, but your ability to learn will always be your biggest strength. Stay curious, keep upgrading yourself, and never stop growing.”
Message me on WhatsApp at +91 99301 12627 and tell me which blog you read. I would love to hear from you.
Mapping your path? See the front-end developer roadmap and our Node.js interview questions.
Frequently asked questions
Which JavaScript topics are asked most for freshers?
Scope and hoisting, var/let/const, closures, the this keyword, == vs ===, the event loop, promises and async/await, and ES6 features such as arrow functions and destructuring.
Do I need JavaScript before React or Node?
Yes. Both are built on JavaScript, so solid fundamentals make learning them much easier and are tested directly in interviews.
How much coding is in a JavaScript interview?
Usually one or two short problems on strings, arrays or objects, plus output-prediction questions on closures, this and async behaviour.
Is JavaScript still worth learning in 2026?
Yes. It runs the web front end, powers back ends through Node.js and appears in most full-stack job descriptions.
Cover image: photo by Pankaj Patel on Unsplash.
Keep reading
Full Stack & ProgrammingPython Developer Roadmap for Freshers (2026): Basics to a Job-Ready PathA step-by-step Python developer roadmap for freshers: the basics, functions and data structures, OOP, files and errors, the package ecosystem, then choosing a direction (web, data/AI…Full Stack & ProgrammingJava Developer Roadmap for Freshers (2026): Core Java to Spring BootFull Stack & ProgrammingGit and GitHub for Beginners (2026): Commands, Workflow and First Steps← Previous articleReact Interview Questions for Freshers (2026): 35 Questions with Clear AnswersNext article →SQL Interview Questions for Freshers (2026): 35 Questions with Answers
