Coding Now – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 9667708830
Home Community What is the difference between var, let, and const in JavaS…

What is the difference between var, let, and const in JavaScript?

Coding Now Expert  •  Jun 13, 2026  •  223 views
All three declare variables, but with different scope and mutability:

**var:** function-scoped, hoisted, can be redeclared
**let:** block-scoped, not hoisted, cannot be redeclared
**const:** block-scoped, cannot be reassigned

```javascript
if (true) {
var x = 1; // accessible outside the if block
let y = 2; // only inside the if block
const z = 3; // only inside, cannot change
}
console.log(x); // 1
console.log(y); // ReferenceError
```

Best practice: Use **const** by default, **let** when reassignment needed, avoid **var**.
0

0 Answers

Your Answer

Will not be displayed publicly
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →