1️⃣ What is Scope in JavaScript?
Answer:
Scope determines where variables are accessible.
- Global Scope → accessible everywhere
- Function Scope → inside function
- Block Scope → inside
{}(let, const)
let a = 10;function test() {
let b = 20;
}
👉 b is not accessible outside the function.
2️⃣ What is Hoisting?
Answer:
Hoisting is JavaScript’s default behavior of moving declarations to the top.
console.log(a); // undefined
var a = 5;
👉 var is hoisted with undefined
⚠️ let and const are hoisted but in Temporal Dead Zone
3️⃣ What is a Closure?
Answer:
A closure is a function that remembers variables from its outer scope.
function outer() {
let count = 0; return function () {
count++;
return count;
};
}let fn = outer();
fn(); // 1
fn(); // 2
👉 Used in:
- Data hiding
- Private variables
- Callbacks
4️⃣ What is Execution Context?
Answer:
Execution context is the environment where JavaScript code runs.
Types:
- Global Execution Context
- Function Execution Context
Phases:
- Memory creation
- Code execution
5️⃣ What is Call Stack?
Answer:
Call stack is a structure that keeps track of function calls (LIFO).
function a() { b(); }
function b() { console.log("Hi"); }a();
👉 Stack:a → b → console.log
6️⃣ What is this keyword?
Answer:this refers to the object that calls the function.
let obj = {
name: "Aditya",
show() {
console.log(this.name);
}
};
Important cases:
- Object → refers to object
- Function → window / undefined
- Arrow → inherits from parent
7️⃣ Difference between call, apply, and bind?
Answer:
function greet(city) {
console.log(this.name + " from " + city);
}let user = { name: "Aditya" };greet.call(user, "Delhi");
greet.apply(user, ["Delhi"]);let fn = greet.bind(user);
fn("Delhi");
👉 Difference:
call→ arguments separatelyapply→ arguments as arraybind→ returns new function
8️⃣ What is Prototype?
Answer:
Prototype is an object from which other objects inherit properties.
function Person(name) {
this.name = name;
}Person.prototype.sayHi = function () {
console.log("Hi " + this.name);
};
9️⃣ What is Prototypal Inheritance?
Answer:
Objects inherit properties from another object.
let parent = {
greet() {
console.log("Hello");
}
};let child = Object.create(parent);
child.greet();
🔟 What is the difference between == and ===?
Answer:
==→ compares value (type conversion happens)===→ compares value + type
"5" == 5 // true
"5" === 5 // false
1️⃣1️⃣ What is Event Loop? (Bonus 🔥)
Answer:
Event loop handles async operations in JavaScript.
👉 Flow:
- Call Stack
- Web APIs
- Callback Queue
- Event Loop
1️⃣2️⃣ What is Temporal Dead Zone?
Answer:
Time between variable hoisting and initialization.
console.log(a); // Error
let a = 10;
1️⃣3️⃣ What are Arrow Functions?
Answer:
Short syntax functions that don’t have their own this.
const add = (a, b) => a + b;
1️⃣4️⃣ What is Difference: var vs let vs const?
| Feature | var | let | const |
|---|---|---|---|
| Scope | Function | Block | Block |
| Hoisting | Yes | Yes (TDZ) | Yes (TDZ) |
| Reassign | Yes | Yes | No |
1️⃣5️⃣ What is a Higher Order Function?
Answer:
Function that takes another function as argument or returns a function.
function greet(fn) {
fn();
}
🚀 Pro Tip for Interviews
Focus on:
- Writing code
- Explaining output
- Real-world examples






