---
title: "What is the difference between var, let and const in JavaScript?"  
description: "What is the difference between var, let and const in JavaScript?"  
author: "Magdalena Michalska"  
published: 2026-11-13  
updated: 2026-11-13  
canonical: https://www.mindstick.com/forum/163010/what-is-the-difference-between-var-let-and-const-in-javascript  
category: "JavaScript and Frontend"  
tags: ["javascript", "var let const", "scope", "hoisting", "ES6"]  
reading_time: 1 minute  

---

# What is the difference between var, let and const in JavaScript?

Tutorials tell me to stop using var. What actually changes between var, let and const?

## Replies

### Reply by Madison Ross

- **var** is function-scoped, can be redeclared, and is hoisted with the value undefined. That can cause surprising bugs, for example a loop variable still existing after the loop.
- **let** is block-scoped (inside the nearest { }) and cannot be used before its declaration. It can be reassigned.
- **const** is also block-scoped and cannot be reassigned.

Note that const protects the binding, not the contents. `const list = []; list.push(1);` is fine. Only `list = []` is an error.

Modern advice: use const by default, use let when you need to reassign, and avoid var. This makes the code easier to reason about, because a reader knows a const never points to something new.


---

Original Source: https://www.mindstick.com/forum/163010/what-is-the-difference-between-var-let-and-const-in-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
