Dev.to
7/2/2026

`var`, `let`, and `const` in JavaScript
Short summary
JavaScript offers three variable declaration methods: `var` (function-scoped, outdated), `let` (block-scoped, for changing values), and `const` (block-scoped, for immutable values). Modern JavaScript development strongly favors `let` and `const` for block scope and accident-prevention.
- •var is function-scoped and prone to bugs; avoid in modern code
- •let and const are block-scoped; let for changing values, const for immutable values
- •Hoisting differs: var initializes to undefined, let/const remain uninitialized (Temporal Dead Zone)
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



