JavaScript Interview Questions for Freshers (2026)

What JavaScript questions are asked to freshers? Interviewers usually ask var vs let vs const, hoisting, == vs ===, closures, the this keyword, arrow functions, array methods (map, filter, reduce), promises and async/await, the event loop and DOM basics. Then they give a few output puzzles and a small coding task. If you can explain each idea in one or two lines and show a tiny code example, you cover most first-round JavaScript interviews.

This guide from VibrantMinds Technologies in Pune gives 50+ JavaScript interview questions and answers, with code, output puzzles, coding tasks, trap questions and a 14-day plan. It is written for anyone searching JavaScript interview questions for freshers, JavaScript interview questions and answers, JavaScript output questions for interview, var vs let vs const interview question, JavaScript closures interview questions, JavaScript promises and async await interview questions, difference between == and === in JavaScript, JavaScript event loop explained for beginners, JavaScript coding questions for freshers or a free IT job WhatsApp group for full stack freshers in Pune.

Takeaway

Detail

Explain, then show code

One-line definition plus a 3 to 5 line example.

Four ideas decide most rounds

Scope and hoisting, closures, this, and async behaviour.

Use === by default

== converts types and can surprise you.

Know the event loop order

Synchronous code, then microtasks (promises), then macrotasks (setTimeout).

Prefer let and const over var

Block scope avoids a whole class of bugs.

Practise output puzzles

They test understanding, not memory.

Be honest

“I’m not sure, but I’d check the documentation” is better than guessing.

HOW A JAVASCRIPT INTERVIEW USUALLY FLOWS




MODULE 1: BASICS AND DATA TYPES (Q1 TO Q10)

Q1. What is JavaScript?
Answer: A high-level, dynamically typed, interpreted language that runs in browsers and, through Node.js, on servers. It’s used to make web pages interactive and to build full stack applications.

Q2. What are the data types in JavaScript?
Answer: Primitives: string, number, bigint, boolean, undefined, null, symbol. Non-primitive: objects (including arrays and functions).

Q3. null vs undefined

Point

undefined

null

Meaning

A variable declared but not assigned

An intentional “no value”

Who sets it

JavaScript

The programmer

typeof

"undefined"

"object" (a long-standing quirk)

Q4. == vs ===
Answer: == compares after type conversion, === compares value and type with no conversion.

javascript

console.log(5 == "5");    // true
console.log(5 === "5");   // false
console.log(null == undefined);   // true
console.log(null === undefined);  // false
console.log(5 == "5");    // true
console.log(5 === "5");   // false
console.log(null == undefined);   // true
console.log(null === undefined);  // false
console.log(5 == "5");    // true
console.log(5 === "5");   // false
console.log(null == undefined);   // true
console.log(null === undefined);  // false

Best practice: use === unless you have a specific reason.

Q5. What is type coercion?
Answer: Automatic conversion of one type to another, for example "3" - 1 gives 2, while 1 + "2" gives "12".

Q6. What is NaN? How do you check for it?
Answer: “Not a Number”, the result of invalid numeric operations. NaN === NaN is false, so use Number.isNaN(value).

Q7. What are truthy and falsy values?
Answer: Falsy values: false, 0, "", null, undefined, NaN (and 0n). Everything else is truthy, including "0", [] and {}.

Q8. What does typeof return for common values?

Expression

Result

typeof 42

"number"

typeof "hi"

"string"

typeof true

"boolean"

typeof undefined

"undefined"

typeof null

"object"

typeof []

"object"

typeof function(){}

"function"

Use Array.isArray(x) to check for arrays.

Q9. What is the difference between primitives and objects in assignment?
Answer: Primitives are copied by value. Objects and arrays are copied by reference, so two variables can point to the same object.

javascript

let a = { n: 1 };
let b = a;
b.n = 99;
console.log(a.n);   // 99
let a = { n: 1 };
let b = a;
b.n = 99;
console.log(a.n);   // 99
let a = { n: 1 };
let b = a;
b.n = 99;
console.log(a.n);   // 99

Q10. Why does 0.1 + 0.2 === 0.3 return false?
Answer: Numbers use binary floating-point, so some decimals can’t be represented exactly. Compare with a small tolerance or use rounding for money-like values.

MODULE 2: VARIABLES, SCOPE AND HOISTING (Q11 TO Q18)

Q11. var vs let vs const

Point

var

let

const

Scope

Function

Block

Block

Re-declare

Allowed

Not allowed in the same scope

Not allowed

Re-assign

Allowed

Allowed

Not allowed

Hoisting

Hoisted, initialised as undefined

Hoisted, but in the temporal dead zone

Same as let

Recommendation

Avoid

Use when the value changes

Use by default

Q12. Does const make an object immutable?
Answer: No. const prevents re-assigning the variable, but the object’s contents can still change. Use Object.freeze() for shallow immutability.

javascript

const user = { name: "Asha" };
user.name = "Ravi";      // allowed
// user = {};             // TypeError
const user = { name: "Asha" };
user.name = "Ravi";      // allowed
// user = {};             // TypeError
const user = { name: "Asha" };
user.name = "Ravi";      // allowed
// user = {};             // TypeError

Q13. What is hoisting?
Answer: JavaScript moves declarations to the top of their scope during the creation phase. Function declarations are fully hoisted. var is hoisted and set to undefined. let and const are hoisted but can’t be used before their declaration.

javascript

console.log(a);   // undefined
var a = 5;

console.log(b);   // ReferenceError (temporal dead zone)
let b = 10;

sayHi();          // works (function declaration is hoisted)
function sayHi() { console.log("Hi"); }
console.log(a);   // undefined
var a = 5;

console.log(b);   // ReferenceError (temporal dead zone)
let b = 10;

sayHi();          // works (function declaration is hoisted)
function sayHi() { console.log("Hi"); }
console.log(a);   // undefined
var a = 5;

console.log(b);   // ReferenceError (temporal dead zone)
let b = 10;

sayHi();          // works (function declaration is hoisted)
function sayHi() { console.log("Hi"); }

Q14. What is the temporal dead zone (TDZ)?
Answer: The period between entering a scope and the line where a let or const variable is declared. Accessing it throws a ReferenceError.

Q15. What is scope? Types?
Answer: The area where a variable is accessible: global, function and block scope.

Q16. What is the scope chain?
Answer: When a variable isn’t found in the current scope, JavaScript looks in the outer scope, then the next, up to the global scope.

Q17. Function declaration vs function expression

javascript

// Declaration (hoisted)
function add(a, b) { return a + b; }

// Expression (not usable before this line)
const subtract = function (a, b) { return a - b; };

// Arrow function
const multiply = (a, b) => a * b;
// Declaration (hoisted)
function add(a, b) { return a + b; }

// Expression (not usable before this line)
const subtract = function (a, b) { return a - b; };

// Arrow function
const multiply = (a, b) => a * b;
// Declaration (hoisted)
function add(a, b) { return a + b; }

// Expression (not usable before this line)
const subtract = function (a, b) { return a - b; };

// Arrow function
const multiply = (a, b) => a * b;

Q18. What is an IIFE?
Answer: An Immediately Invoked Function Expression, a function that runs as soon as it is defined, often used to create a private scope.

javascript

(function () { console.log("Runs immediately"); })();
(function () { console.log("Runs immediately"); })();
(function () { console.log("Runs immediately"); })();

MODULE 3: FUNCTIONS, CLOSURES AND this (Q19 TO Q28)

Q19. What is a closure?
Answer: A closure is a function that remembers the variables from the scope where it was created, even after that outer function has finished.

javascript

function makeCounter() {
  let count = 0;
  return function () {
    count++;
    return count;
  };
}

const counter = makeCounter();
console.log(counter());   // 1
console.log(counter());   // 2
function makeCounter() {
  let count = 0;
  return function () {
    count++;
    return count;
  };
}

const counter = makeCounter();
console.log(counter());   // 1
console.log(counter());   // 2
function makeCounter() {
  let count = 0;
  return function () {
    count++;
    return count;
  };
}

const counter = makeCounter();
console.log(counter());   // 1
console.log(counter());   // 2

count stays alive because the inner function still references it. It is also private: nothing outside can change it directly.

Q20. Where are closures used in real code?
Answer: Data privacy, counters, memoization, event handlers, callbacks and function factories.

Q21. The classic closure-in-a-loop question

javascript

for (var i = 0; i < 3; i++) {
  setTimeout(() => console.log(i), 0);
}
// 3 3 3

for (let j = 0; j < 3; j++) {
  setTimeout(() => console.log(j), 0);
}
// 0 1 2
for (var i = 0; i < 3; i++) {
  setTimeout(() => console.log(i), 0);
}
// 3 3 3

for (let j = 0; j < 3; j++) {
  setTimeout(() => console.log(j), 0);
}
// 0 1 2
for (var i = 0; i < 3; i++) {
  setTimeout(() => console.log(i), 0);
}
// 3 3 3

for (let j = 0; j < 3; j++) {
  setTimeout(() => console.log(j), 0);
}
// 0 1 2

Why: var has one function-scoped i, so by the time the callbacks run it equals 3. let creates a new binding for each iteration.

Q22. What is a callback?
Answer: A function passed as an argument to be called later.

Q23. What are higher-order functions?
Answer: Functions that take other functions as arguments or return functions, such as map, filter, reduce and forEach.

Q24. What is the this keyword?
Answer: A reference to the object that is executing the current function. Its value depends on how the function is called.

Situation

this refers to

Method call obj.method()

obj

Plain function call (non-strict)

The global object (window in browsers)

Plain function call (strict mode)

undefined

Arrow function

this from the surrounding scope

new Constructor()

The new object

call, apply, bind

The object you pass in

Q25. Arrow function vs regular function

Point

Regular function

Arrow function

this

Depends on the call

Inherits from the outer scope

arguments object

Yes

No

Can be a constructor (new)

Yes

No

Syntax

Longer

Shorter

javascript

const person = {
  name: "Asha",
  regular() { return this.name; },          // "Asha"
  arrow: () => typeof this.name,            // not the object's name (this is from outside)
};
const person = {
  name: "Asha",
  regular() { return this.name; },          // "Asha"
  arrow: () => typeof this.name,            // not the object's name (this is from outside)
};
const person = {
  name: "Asha",
  regular() { return this.name; },          // "Asha"
  arrow: () => typeof this.name,            // not the object's name (this is from outside)
};

Q26. call, apply and bind

javascript

function greet(greeting) { return greeting + ", " + this.name; }
const user = { name: "Asha" };

greet.call(user, "Hello");        // "Hello, Asha"
greet.apply(user, ["Hello"]);     // "Hello, Asha"
const bound = greet.bind(user);   // returns a new function
bound("Hi");                      // "Hi, Asha"
function greet(greeting) { return greeting + ", " + this.name; }
const user = { name: "Asha" };

greet.call(user, "Hello");        // "Hello, Asha"
greet.apply(user, ["Hello"]);     // "Hello, Asha"
const bound = greet.bind(user);   // returns a new function
bound("Hi");                      // "Hi, Asha"
function greet(greeting) { return greeting + ", " + this.name; }
const user = { name: "Asha" };

greet.call(user, "Hello");        // "Hello, Asha"
greet.apply(user, ["Hello"]);     // "Hello, Asha"
const bound = greet.bind(user);   // returns a new function
bound("Hi");                      // "Hi, Asha"

Difference: call takes arguments one by one, apply takes an array and bind returns a new function without calling it.

Q27. What are default and rest parameters?

javascript

function greet(name = "Guest") { return "Hi " + name; }
function sum(...nums) { return nums.reduce((a, b) => a + b, 0); }
function greet(name = "Guest") { return "Hi " + name; }
function sum(...nums) { return nums.reduce((a, b) => a + b, 0); }
function greet(name = "Guest") { return "Hi " + name; }
function sum(...nums) { return nums.reduce((a, b) => a + b, 0); }

Q28. What is a pure function?
Answer: A function that returns the same output for the same input and has no side effects, which makes it easy to test.

MODULE 4: ARRAYS, OBJECTS AND ES6 (Q29 TO Q38)

Q29. map, filter and reduce

javascript

const nums = [1, 2, 3, 4, 5];

nums.map(n => n * 2);              // [2, 4, 6, 8, 10]   transform each
nums.filter(n => n % 2 === 0);     // [2, 4]              keep matching
nums.reduce((sum, n) => sum + n, 0); // 15                combine into one value
const nums = [1, 2, 3, 4, 5];

nums.map(n => n * 2);              // [2, 4, 6, 8, 10]   transform each
nums.filter(n => n % 2 === 0);     // [2, 4]              keep matching
nums.reduce((sum, n) => sum + n, 0); // 15                combine into one value
const nums = [1, 2, 3, 4, 5];

nums.map(n => n * 2);              // [2, 4, 6, 8, 10]   transform each
nums.filter(n => n % 2 === 0);     // [2, 4]              keep matching
nums.reduce((sum, n) => sum + n, 0); // 15                combine into one value

Q30. forEach vs map
Answer: forEach runs a function for each item and returns undefined. map returns a new array of transformed values.

Q31. What are find, some and every?

javascript

const users = [{ id: 1, age: 20 }, { id: 2, age: 17 }];
users.find(u => u.id === 2);        // { id: 2, age: 17 }
users.some(u => u.age < 18);        // true
users.every(u => u.age >= 18);      // false
const users = [{ id: 1, age: 20 }, { id: 2, age: 17 }];
users.find(u => u.id === 2);        // { id: 2, age: 17 }
users.some(u => u.age < 18);        // true
users.every(u => u.age >= 18);      // false
const users = [{ id: 1, age: 20 }, { id: 2, age: 17 }];
users.find(u => u.id === 2);        // { id: 2, age: 17 }
users.some(u => u.age < 18);        // true
users.every(u => u.age >= 18);      // false

Q32. What is destructuring?

javascript

const { name, age } = { name: "Asha", age: 21 };
const [first, second] = [10, 20, 30];
const { name, age } = { name: "Asha", age: 21 };
const [first, second] = [10, 20, 30];
const { name, age } = { name: "Asha", age: 21 };
const [first, second] = [10, 20, 30];

Q33. Spread vs rest

javascript

const a = [1, 2];
const b = [...a, 3, 4];             // spread: expands -> [1,2,3,4]
const copy = { ...{ x: 1 }, y: 2 }; // object spread -> { x:1, y:2 }

function total(...nums) {}          // rest: collects arguments
const a = [1, 2];
const b = [...a, 3, 4];             // spread: expands -> [1,2,3,4]
const copy = { ...{ x: 1 }, y: 2 }; // object spread -> { x:1, y:2 }

function total(...nums) {}          // rest: collects arguments
const a = [1, 2];
const b = [...a, 3, 4];             // spread: expands -> [1,2,3,4]
const copy = { ...{ x: 1 }, y: 2 }; // object spread -> { x:1, y:2 }

function total(...nums) {}          // rest: collects arguments

Q34. Shallow copy vs deep copy
Answer: A shallow copy (spread, Object.assign) copies only the top level, so nested objects are still shared. A deep copy duplicates everything. Use structuredClone(obj) in modern environments.

Q35. What are template literals?

javascript

const name = "Asha";
console.log(`Hello, ${name}!`);
const name = "Asha";
console.log(`Hello, ${name}!`);
const name = "Asha";
console.log(`Hello, ${name}!`);

Q36. What are Set and Map?
Answer: Set stores unique values. Map stores key-value pairs where keys can be any type.

javascript

const unique = [...new Set([1, 2, 2, 3])];   // [1, 2, 3]
const unique = [...new Set([1, 2, 2, 3])];   // [1, 2, 3]
const unique = [...new Set([1, 2, 2, 3])];   // [1, 2, 3]

Q37. What is optional chaining (?.) and nullish coalescing (??)?

javascript

const city = user?.address?.city;      // undefined instead of an error
const count = input ?? 0;              // 0 only if input is null or undefined
const city = user?.address?.city;      // undefined instead of an error
const count = input ?? 0;              // 0 only if input is null or undefined
const city = user?.address?.city;      // undefined instead of an error
const count = input ?? 0;              // 0 only if input is null or undefined

?? differs from || because || also replaces 0 and "".

Q38. What are ES modules?
Answer: The standard way to split code using export and import.

javascript

// math.js
export const add = (a, b) => a + b;
// app.js
import { add } from "./math.js";
// math.js
export const add = (a, b) => a + b;
// app.js
import { add } from "./math.js";
// math.js
export const add = (a, b) => a + b;
// app.js
import { add } from "./math.js";

MODULE 5: ASYNCHRONOUS JAVASCRIPT (Q39 TO Q48)

Q39. Why is JavaScript called single-threaded?
Answer: It has one call stack and runs one piece of code at a time. Asynchronous work (timers, network calls) is handled by the browser or Node.js and its results come back through queues.

Q40. How does the event loop work?




Order: run all synchronous code, then all queued microtasks (promise callbacks), then one macrotask (such as a setTimeout callback), then repeat.

Q41. What is the output?

javascript

console.log("A");
setTimeout(() => console.log("B"), 0);
Promise.resolve().then(() => console.log("C"));
console.log("D");
// A D C B
console.log("A");
setTimeout(() => console.log("B"), 0);
Promise.resolve().then(() => console.log("C"));
console.log("D");
// A D C B
console.log("A");
setTimeout(() => console.log("B"), 0);
Promise.resolve().then(() => console.log("C"));
console.log("D");
// A D C B

Q42. What is a callback hell? How do you avoid it?
Answer: Deeply nested callbacks that are hard to read. Avoid it with promises or async/await and by splitting code into small functions.

Q43. What is a Promise?
Answer: An object representing the eventual result of an asynchronous operation. It has three states: pending, fulfilled and rejected.

javascript

const p = new Promise((resolve, reject) => {
  setTimeout(() => resolve("Done"), 1000);
});
p.then(console.log).catch(console.error).finally(() => console.log("End"));
const p = new Promise((resolve, reject) => {
  setTimeout(() => resolve("Done"), 1000);
});
p.then(console.log).catch(console.error).finally(() => console.log("End"));
const p = new Promise((resolve, reject) => {
  setTimeout(() => resolve("Done"), 1000);
});
p.then(console.log).catch(console.error).finally(() => console.log("End"));

Q44. async/await

javascript

async function loadUser(id) {
  try {
    const res = await fetch(`/api/users/${id}`);
    if (!res.ok) throw new Error("Request failed: " + res.status);
    return await res.json();
  } catch (err) {
    console.error(err.message);
    return null;
  }
}
async function loadUser(id) {
  try {
    const res = await fetch(`/api/users/${id}`);
    if (!res.ok) throw new Error("Request failed: " + res.status);
    return await res.json();
  } catch (err) {
    console.error(err.message);
    return null;
  }
}
async function loadUser(id) {
  try {
    const res = await fetch(`/api/users/${id}`);
    if (!res.ok) throw new Error("Request failed: " + res.status);
    return await res.json();
  } catch (err) {
    console.error(err.message);
    return null;
  }
}

Key points: async functions always return a promise, await pauses the function (not the whole program) until the promise settles and errors are handled with try/catch.

Q45. Promise.all, allSettled, race and any

Method

Behaviour

Promise.all([...])

Resolves when all succeed, rejects if any fails

Promise.allSettled([...])

Waits for all and reports each result, never rejects

Promise.race([...])

Settles with the first promise to settle

Promise.any([...])

Resolves with the first success, rejects if all fail

Q46. Sequential vs parallel awaits

javascript

// Sequential (slower)
const a = await getA();
const b = await getB();

// Parallel (faster when independent)
const [a2, b2] = await Promise.all([getA(), getB()]);
// Sequential (slower)
const a = await getA();
const b = await getB();

// Parallel (faster when independent)
const [a2, b2] = await Promise.all([getA(), getB()]);
// Sequential (slower)
const a = await getA();
const b = await getB();

// Parallel (faster when independent)
const [a2, b2] = await Promise.all([getA(), getB()]);

Q47. What does fetch return, and does it reject on a 404?
Answer: fetch returns a promise for a Response. It rejects only on network failures. For HTTP errors such as 404 or 500 it still resolves, so check res.ok or res.status.

Q48. What are setTimeout and setInterval?
Answer: setTimeout runs a function once after a delay. setInterval runs it repeatedly. Clear them with clearTimeout and clearInterval. A delay of 0 still runs after the current synchronous code.

MODULE 6: DOM AND BROWSER BASICS (Q49 TO Q54)

Q49. What is the DOM?
Answer: The Document Object Model, a tree representation of a web page that JavaScript can read and change.

Q50. How do you select and change elements?

javascript

const title = document.querySelector("#title");
const items = document.querySelectorAll(".item");
title.textContent = "Hello";
title.classList.add("active");
const title = document.querySelector("#title");
const items = document.querySelectorAll(".item");
title.textContent = "Hello";
title.classList.add("active");
const title = document.querySelector("#title");
const items = document.querySelectorAll(".item");
title.textContent = "Hello";
title.classList.add("active");

Q51. What is event bubbling and event delegation?
Answer: Bubbling: an event on a child element travels up through its parents. Delegation: attach one listener to a parent and handle child events using event.target, which is efficient for dynamic lists.

javascript

document.querySelector("#list").addEventListener("click", (e) => {
  if (e.target.matches("li")) console.log(e.target.textContent);
});
document.querySelector("#list").addEventListener("click", (e) => {
  if (e.target.matches("li")) console.log(e.target.textContent);
});
document.querySelector("#list").addEventListener("click", (e) => {
  if (e.target.matches("li")) console.log(e.target.textContent);
});

Q52. localStorage vs sessionStorage vs cookies

Storage

Lifetime

Sent to server automatically

localStorage

Until cleared

No

sessionStorage

Until the tab closes

No

Cookies

Until expiry

Yes, with requests

Never store passwords or sensitive tokens carelessly in browser storage.

Q53. What is JSON and how do you use it?

javascript

const text = JSON.stringify({ name: "Asha", age: 21 });
const obj = JSON.parse(text);
const text = JSON.stringify({ name: "Asha", age: 21 });
const obj = JSON.parse(text);
const text = JSON.stringify({ name: "Asha", age: 21 });
const obj = JSON.parse(text);

Q54. innerHTML vs textContent
Answer: innerHTML parses HTML and can introduce XSS risk if it contains user input. textContent inserts plain text and is safer.

OUTPUT PUZZLES (PREDICT BEFORE YOU RUN)

Puzzle 1

javascript

console.log(typeof null);
console.log(typeof undefined);
console.log(typeof null);
console.log(typeof undefined);
console.log(typeof null);
console.log(typeof undefined);

Output: object, then undefined.

Puzzle 2

javascript

console.log(1 + "2");
console.log("3" - 1);
console.log(true + 1);
console.log(1 + "2");
console.log("3" - 1);
console.log(true + 1);
console.log(1 + "2");
console.log("3" - 1);
console.log(true + 1);

Output: 12, 2, 2.

Puzzle 3

javascript

console.log(0.1 + 0.2 === 0.3);
console.log([] == false);
console.log(0.1 + 0.2 === 0.3);
console.log([] == false);
console.log(0.1 + 0.2 === 0.3);
console.log([] == false);

Output: false, true. ([] converts to an empty string, then to 0, so it equals false with ==.)

Puzzle 4

javascript

var x = 1;
function test() {
  console.log(x);
  var x = 2;
}
test();
var x = 1;
function test() {
  console.log(x);
  var x = 2;
}
test();
var x = 1;
function test() {
  console.log(x);
  var x = 2;
}
test();

Output: undefined. The local var x is hoisted inside test, so the outer x is hidden.

Puzzle 5

javascript

console.log(NaN === NaN);
console.log([1, 2, 3].includes(NaN));
console.log([NaN].includes(NaN));
console.log(NaN === NaN);
console.log([1, 2, 3].includes(NaN));
console.log([NaN].includes(NaN));
console.log(NaN === NaN);
console.log([1, 2, 3].includes(NaN));
console.log([NaN].includes(NaN));

Output: false, false, true. (includes uses a comparison that treats NaN as equal to NaN.)

Puzzle 6

javascript

const obj = { a: 1 };
const copy = obj;
copy.a = 5;
console.log(obj.a);
const obj = { a: 1 };
const copy = obj;
copy.a = 5;
console.log(obj.a);
const obj = { a: 1 };
const copy = obj;
copy.a = 5;
console.log(obj.a);

Output: 5. Both variables reference the same object.

CODING ROUND: 8 TASKS WITH SOLUTIONS

1. Reverse a string

javascript

const reverse = (s) => s.split("").reverse().join("");
// reverse("VibrantMinds") -> "sdniMtnarbiV"
const reverse = (s) => s.split("").reverse().join("");
// reverse("VibrantMinds") -> "sdniMtnarbiV"
const reverse = (s) => s.split("").reverse().join("");
// reverse("VibrantMinds") -> "sdniMtnarbiV"

2. Check a palindrome

javascript

const isPalindrome = (s) => {
  const clean = s.toLowerCase().replace(/[^a-z0-9]/g, "");
  return clean === clean.split("").reverse().join("");
};
const isPalindrome = (s) => {
  const clean = s.toLowerCase().replace(/[^a-z0-9]/g, "");
  return clean === clean.split("").reverse().join("");
};
const isPalindrome = (s) => {
  const clean = s.toLowerCase().replace(/[^a-z0-9]/g, "");
  return clean === clean.split("").reverse().join("");
};

3. Remove duplicates from an array

javascript

const unique = (arr) => [...new Set(arr)];
const unique = (arr) => [...new Set(arr)];
const unique = (arr) => [...new Set(arr)];

4. Count character frequency

javascript

const freq = (s) => {
  const map = {};
  for (const ch of s) map[ch] = (map[ch] || 0) + 1;
  return map;
};
// freq("hello") -> { h:1, e:1, l:2, o:1 }
const freq = (s) => {
  const map = {};
  for (const ch of s) map[ch] = (map[ch] || 0) + 1;
  return map;
};
// freq("hello") -> { h:1, e:1, l:2, o:1 }
const freq = (s) => {
  const map = {};
  for (const ch of s) map[ch] = (map[ch] || 0) + 1;
  return map;
};
// freq("hello") -> { h:1, e:1, l:2, o:1 }

5. Find the largest number

javascript

const max = (arr) => Math.max(...arr);
const max = (arr) => Math.max(...arr);
const max = (arr) => Math.max(...arr);

6. FizzBuzz

javascript

for (let i = 1; i <= 15; i++) {
  console.log(i % 15 === 0 ? "FizzBuzz" : i % 3 === 0 ? "Fizz" : i % 5 === 0 ? "Buzz" : i);
}
for (let i = 1; i <= 15; i++) {
  console.log(i % 15 === 0 ? "FizzBuzz" : i % 3 === 0 ? "Fizz" : i % 5 === 0 ? "Buzz" : i);
}
for (let i = 1; i <= 15; i++) {
  console.log(i % 15 === 0 ? "FizzBuzz" : i % 3 === 0 ? "Fizz" : i % 5 === 0 ? "Buzz" : i);
}

7. Flatten a nested array

javascript

const flat = [1, [2, [3, [4]]]].flat(Infinity);   // [1, 2, 3, 4]
const flat = [1, [2, [3, [4]]]].flat(Infinity);   // [1, 2, 3, 4]
const flat = [1, [2, [3, [4]]]].flat(Infinity);   // [1, 2, 3, 4]

8. Write a simple debounce

javascript

function debounce(fn, delay) {
  let timer;
  return function (...args) {
    clearTimeout(timer);
    timer = setTimeout(() => fn.apply(this, args), delay);
  };
}
// Runs fn only after the user stops triggering it for `delay` ms (good for search boxes)
function debounce(fn, delay) {
  let timer;
  return function (...args) {
    clearTimeout(timer);
    timer = setTimeout(() => fn.apply(this, args), delay);
  };
}
// Runs fn only after the user stops triggering it for `delay` ms (good for search boxes)
function debounce(fn, delay) {
  let timer;
  return function (...args) {
    clearTimeout(timer);
    timer = setTimeout(() => fn.apply(this, args), delay);
  };
}
// Runs fn only after the user stops triggering it for `delay` ms (good for search boxes)

It’s a closure in action, because timer is remembered between calls.

TRAP QUESTIONS INTERVIEWERS ASK

Trap

Correct thinking

“Is JavaScript the same as Java?”

No. They are different languages with different designs.

“Does const make an object immutable?”

No, only the binding is constant.

“Is typeof null null?”

It returns "object", a historical quirk.

“Is setTimeout(fn, 0) instant?”

No, it runs after the current code and pending microtasks.

“Does forEach work with await as expected?”

It does not wait for async callbacks. Use for...of or Promise.all.

“Does fetch reject on a 404?”

No, check res.ok.

“Is [] + [] an array?”

It becomes an empty string.

“Are arrow functions just shorter syntax?”

They also change how this works.

COMMON MISTAKES FRESHERS MAKE IN JAVASCRIPT INTERVIEWS

Mistake

Why it hurts

Better approach

Memorising definitions only

Output puzzles expose gaps

Run every example yourself

Using == casually

Surprising conversions

Use ===

Confusing hoisting for let and var

Common question

Remember TDZ vs undefined

Not knowing the event loop

A favourite round-two topic

Learn the microtask-then-macrotask order

Forgetting error handling in async code

Looks careless

Use try/catch and check res.ok

Mutating arrays and objects accidentally

Hidden bugs

Learn spread, map and filter

Not explaining while coding

Interviewer can’t follow

Narrate your logic

Calling everything “fast” or “slow” without reasons

Weak answers

Mention complexity and trade-offs

14-DAY JAVASCRIPT PREPARATION PLAN

Day

Focus

Task

1

Data types and coercion

Q1 to Q10, == vs ===, typeof table

2

var, let, const

Q11 to Q14, write hoisting examples

3

Scope and functions

Q15 to Q18, declarations vs expressions

4

Closures

Q19 to Q21, build a counter and the loop example

5

this

Q24 to Q26, practise call, apply, bind

6

Arrays

Q29 to Q31, practise map, filter, reduce on small data

7

ES6 features

Q32 to Q38, destructuring, spread, optional chaining

8

Event loop

Q39 to Q41, predict outputs of 5 sequences

9

Promises

Q43 and Q45, write your own promise

10

async/await and fetch

Q44, Q46 to Q47, call a public API with error handling

11

DOM and events

Q49 to Q54, build a small to-do page

12

Output puzzles

Solve all six, then write two of your own

13

Coding tasks

Solve the 8 tasks without looking

14

Mock interview

Answer Q1 to Q54 aloud and explain your best project

MYTH VS REALITY

Myth

Reality

“JavaScript is easy, so interviews are easy.”

Interviewers test scope, closures and async behaviour deeply.

“Frameworks mean I don’t need core JavaScript.”

React and others are built on these fundamentals.

“var and let are the same.”

Scope and hoisting differ.

“async/await makes code synchronous.”

It looks synchronous but remains asynchronous.

“Output puzzles are tricks.”

They test whether you understand how the language works.

“Java and JavaScript are related.”

Same word, different languages.

HOW VIBRANTMINDS HELPS FRESHERS BUILD FULL STACK SKILLS

VibrantMinds Technologies Pvt. Ltd. is a Pune-based IT training and placement support company. If you searched for VibrantMinds or VibrantMinds Technologies, here is what it offers:

  • Full Stack Java Development (about 4 to 6 months): Core Java, OOP, JDBC, SQL, Spring Boot, REST APIs, HTML, CSS, JavaScript and front-end basics, projects, aptitude and interview preparation. Please check the candidate portal for the latest syllabus and tools.

  • Software Testing (Manual + Automation), Core Java and Python & Data Science for other career paths

  • Project practice: Build full stack projects you can host on GitHub and explain confidently

  • Interview preparation: Technical rounds, coding practice, project rounds, HR rounds, aptitude, communication and mock interviews

  • Placement support: Screening, drive coordination and interview support. Check https://candidates.vibrantminds.in/ for current openings.

  • Free WhatsApp job alert groups for fresher IT jobs, campus drives and walk-in alerts

  • Honesty first: VibrantMinds offers placement support, not a guaranteed job, and no legitimate recruiter should ask you to pay to be interviewed.

VibrantMinds works as a talent ecosystem connecting candidates, colleges and companies, with 1900+ partner colleges and 600+ hiring companies. More fresher job guidance: https://candidates.vibrantminds.in/blog/fresher-jobs-pune-2026

VIBRANTMINDS COURSES AT A GLANCE

Course

Duration

Key topics

Full Stack Java Development

4 to 6 months

Core Java, OOP, JDBC, SQL, Spring Boot, REST APIs, front-end basics, projects, aptitude and interview preparation

Software Testing (Manual + Automation)

2 to 5 months

Test cases, STLC, bug tracking, SQL, Selenium basics

Core Java

1 to 2 months

Syntax, OOP, collections, exceptions, strings

Python & Data Science

2 to 4 months

Python basics, data handling, analysis fundamentals

Fees, syllabus and batch dates are on https://candidates.vibrantminds.in/. Please confirm them directly before enrolling.

THE VIBRANTMINDS PLACEMENT PIPELINE: SIX STEPS




REAL OUTCOMES: WHAT TO EXPECT AND WHAT NOT TO

Past students have shared positive feedback about the training and support, and have gone on to roles at companies such as Aress Software and Education Technologies, Saama Technologies and Three M Software. Results vary by candidate, skill level, effort and market conditions, so please confirm details directly with the VibrantMinds team. No one can honestly promise a guaranteed job.

JOIN FREE VIBRANTMINDS WHATSAPP GROUPS: FREE IT JOB UPDATES FOR FULL STACK AND JAVA FRESHERS IN PUNE AND INDIA

Looking for free WhatsApp groups, free IT job WhatsApp groups, a Java WhatsApp group for freshers or a job updates WhatsApp group in India? The VibrantMinds groups share fresher IT openings, campus drives, walk-in interview alerts and interview preparation updates, free of charge. Join whichever group has space. All three carry the same type of updates.

Group

What it offers

Link

VibrantMinds Fresher IT Jobs, Group 1

Fresher openings, campus drives, walk-in alerts

https://chat.whatsapp.com/CUCS1derlmTFee2c9dyUHd

VibrantMinds Fresher IT Jobs, Group 2

Fresher openings, campus drives, walk-in alerts

https://chat.whatsapp.com/FvMf1fGYQYnHppQ8AwFX40

VibrantMinds Fresher IT Jobs, Group 3

Fresher openings, campus drives, walk-in alerts

https://chat.whatsapp.com/I7RNnGMkb2L8S8HibdyWpQ

Never pay to apply. Legitimate recruiters do not charge candidates for tests, interviews or offer letters. Do not share sensitive personal or financial details in any group chat.

FREQUENTLY ASKED QUESTIONS

1. What are the most asked JavaScript interview questions for freshers?
The difference between var, let and const, hoisting, == vs ===, closures, the this keyword, arrow functions, map, filter and reduce, promises, async/await, the event loop, DOM basics and output puzzles. Many interviews also include a small coding task such as reversing a string or removing duplicates.

2. What is hoisting in JavaScript with an example?
Hoisting means declarations are processed before code runs. A var variable is hoisted and holds undefined until assigned, so console.log(a); var a = 5; prints undefined. let and const are hoisted too, but using them before their declaration throws a ReferenceError because of the temporal dead zone.

3. What is a closure in JavaScript with a simple example?
A closure is a function that remembers the variables from the scope where it was created, even after the outer function has finished. For example, a makeCounter() function that returns an inner function keeps its private count variable, and each call to the inner function increases it.

4. How does the JavaScript event loop work for beginners?
JavaScript runs synchronous code on the call stack first. When the stack is empty, the event loop runs all queued microtasks (promise callbacks), then one macrotask (such as a setTimeout callback), and repeats. That is why a promise callback runs before a setTimeout of 0.

5. Is there a free WhatsApp group for full stack freshers in Pune?
Yes. VibrantMinds runs free fresher IT job WhatsApp groups that share Java, full stack and other IT openings, campus drives and walk-in alerts. Join through the links above, and always verify a job post and never pay to apply.

CONCLUSION: UNDERSTAND THE ENGINE, NOT JUST THE SYNTAX

The best way to handle JavaScript interview questions for freshers is to understand how the language really works: scope and hoisting, closures, this, promises and the event loop. Run every example, predict the output puzzles before checking, practise the coding tasks, explain answers aloud and follow the 14-day plan. Honest, clear explanations beat memorised definitions.

If you’re in Pune and want structured Java full stack training with JavaScript, projects, interview preparation and placement support, VibrantMinds Technologies is here to help.

Call to action:

VISIT OR CONTACT VIBRANTMINDS IN PUNE

Office Address

Viva Academy Building, Near St. Mary's Church & Petrol Pump Mumbai-Bangalore Highway, Warje, near to Karvenagar, Pune, Maharashtra 411058

Phone Number

+91 95035 79517

© 2025 VibrantMinds Technologies Pvt. Ltd All Right Reserved

Office Address

Viva Academy Building, Near St. Mary's Church & Petrol Pump Mumbai-Bangalore Highway, Warje, near to Karvenagar, Pune, Maharashtra 411058

Phone Number

+91 95035 79517

© 2025 VibrantMinds Technologies Pvt. Ltd All Right Reserved

Office Address

Viva Academy Building, Near St. Mary's Church & Petrol Pump Mumbai-Bangalore Highway, Warje, near to Karvenagar, Pune, Maharashtra 411058

Phone Number

+91 95035 79517

© 2025 VibrantMinds Technologies Pvt. Ltd All Right Reserved