WhatsApp Group Join Now
Telegram Group Join Now
Instagram Group Join Now

JavaScript Interview Questions for Freshers 2025

Contents

WhatsApp Group Join Now
Telegram Group Join Now
Instagram Group Join Now

50+ JavaScript Interview Questions for Freshers 2025

If you’ve applied to multiple companies but haven’t received a response, fill out this form to explore more opportunities. Click Here

Get the most commonly asked JavaScript interview questions for freshers in 2024. Prepare for coding interviews with real-world JS concepts and examples.

Work From Home
startupremotejobs

Introduction

JavaScript is one of the most in-demand programming languages for front-end and full-stack development. If you’re a fresher preparing for your JavaScript job interview, this guide will help you with the most commonly asked JavaScript interview questions and answers.

Basic JavaScript Interview Questions

1. What is JavaScript?

JavaScript is a scripting language used for building dynamic web applications. It is widely used for frontend and backend development.

2. What are the different data types in JavaScript?

JavaScript has two types of data types:

  • Primitive: Number, String, Boolean, Undefined, Null, Symbol, BigInt
  • Non-primitive: Object, Array, Function

3. What is the difference between var, let, and const?

  • var is function-scoped and can be redeclared.
  • let is block-scoped and cannot be redeclared.
  • const is block-scoped and cannot be reassigned.

4. What is Hoisting in JavaScript?

Hoisting moves variable and function declarations to the top of their scope before execution.

console.log(x); // undefined
var x = 10;

5. What are JavaScript Operators?

  • Arithmetic: +, -, *, /, %, ++, --
  • Comparison: ==, ===, !=, !==, >, <, >=, <=
  • Logical: &&, ||, !
  • Bitwise: &, |, ^, ~, <<, >>

6. How do you check the type of variable?

Use typeof operator:

console.log(typeof "Hello"); // string
console.log(typeof 10); // number

7. What is the difference between == and ===?

  • == checks value only (5 == "5" → true).
  • === checks value and type (5 === "5" → false).

8. What are Template Literals in JavaScript?

Template literals use backticks (`) instead of quotes and allow embedded expressions:

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

9. What is the use of the this keyword?

The this keyword refers to the current object.

let person = {
name: "Alice",
greet() {
console.log(`Hello, ${this.name}`);
}
};
person.greet(); // Hello, Alice

10. How do you create an object in JavaScript?

Using object literals:

let person = {
name: "John",
age: 30
};

Intermediate JavaScript Interview Questions

11. What is Closures in JavaScript?

Closures allow a function to remember variables from its outer scope.

function outer() {
let count = 0;
return function inner() {
count++;
console.log(count);
};
}
const increment = outer();
increment(); // 1
increment(); // 2

12. What is an IIFE (Immediately Invoked Function Expression)?

An IIFE runs immediately after creation:

(function() {
console.log("Hello, World!");
})();

13. What is the difference between null and undefined?

  • null is an intentional absence of a value.
  • undefined means the variable is declared but not assigned.

14. What is the difference between synchronous and asynchronous JavaScript?

  • Synchronous: Code executes line by line.
  • Asynchronous: Some code waits (e.g., API calls) without blocking execution.

15. What are JavaScript Promises?

A Promise represents an asynchronous operation with three states: Pending, Resolved, Rejected.

let myPromise = new Promise((resolve, reject) => {
let success = true;
success ? resolve("Success!") : reject("Error!");
});

16. What is the Event Loop in JavaScript?

The Event Loop allows JavaScript to handle asynchronous operations on a single thread.

17. What is the difference between map(), filter(), and reduce()?

  • map(): Transforms each element.
  • filter(): Returns elements that meet a condition.
  • reduce(): Accumulates values.

18. How does async/await work?

It makes asynchronous code look synchronous.

async function fetchData() {
let response = await fetch("https://api.example.com/data");
let data = await response.json();
console.log(data);
}

19. How to deep clone an object in JavaScript?

Use JSON.parse(JSON.stringify(object)) or structuredClone().

20. What is a WeakMap in JavaScript?

A WeakMap is a collection of key-value pairs where keys are objects, and values can be garbage collected.


📌 Advanced JavaScript Interview Questions

21. What is Prototypal Inheritance?

Objects inherit properties from their prototype:

function Person(name) {
this.name = name;
}
Person.prototype.greet = function() {
console.log(`Hello, ${this.name}`);
};

22. How does bind(), call(), and apply() work?

  • call(): Calls a function with individual arguments.
  • apply(): Calls a function with arguments as an array.
  • bind(): Returns a new function with this bound.

23. What is Memoization?

Caching function results for performance optimization.

24. What is the difference between deep copy and shallow copy?

  • Shallow copy: Only copies references (Object.assign()).
  • Deep copy: Copies entire objects (JSON.parse(JSON.stringify())).

25. What is the Temporal Dead Zone in JavaScript?

The time between variable creation and initialization where it’s inaccessible.

26. What is Function Currying?

A technique where a function returns another function.

const add = (a) => (b) => a + b;
console.log(add(2)(3)); // 5

27. What are Web Workers in JavaScript?

Web Workers allow background execution.

28. What is a JavaScript Proxy?

A Proxy allows customization of object behavior.

let obj = new Proxy({}, {
get(target, prop) {
return prop in target ? target[prop] : "Not found";
}
});
console.log(obj.name); // Not found

29. What are ES6 Modules?

ES6 Modules allow exporting/importing functions across files.

export function greet() { return "Hello"; }
import { greet } from './module.js';
WhatsApp Group Join Now
Telegram Group Join Now
Instagram Group Join Now