JavaScript Interview Questions &
Answers (3+ Years Experience Level)
1. Difference between var, let, and const?
**English:**
`var` is function-scoped and allows redeclaration; it’s hoisted with `undefined`. `let` and `const`
are block-scoped. `let` allows reassignment but not redeclaration, while `const` does not allow
either. Use `let` for mutable and `const` for immutable references.
**Hinglish:**
`var` ka scope function ke andar hota hai aur usko redeclare bhi kar sakte hain. `let` aur `const`
block scoped hote hain. `let` ko update kar sakte hain but dobara declare nahi kar sakte. `const`
na hi update ho sakta hai, na hi redeclare.
2. What is hoisting in JavaScript?
**English:**
Hoisting is JavaScript’s behavior of moving declarations to the top of the scope during
compilation phase. Variables declared with `var` are hoisted with value `undefined`, whereas
`let` and `const` are hoisted but stay in Temporal Dead Zone until initialized.
**Hinglish:**
JavaScript me hoisting ka matlab hota hai variable ya function ke declaration ko scope ke top pe
le jana. `var` undefined ke saath hoist hota hai, jabki `let` aur `const` sirf hoist hote hain lekin
TDZ me rehte hain jab tak unhe assign nahi karte.