---
title: "let vs const vs var in JavaScript"
license: CC-BY-SA-4.0
license_url: https://creativecommons.org/licenses/by-sa/4.0/
source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let
source_license: "CC BY-SA 2.5 (MDN Web Docs content by Mozilla Contributors)"
attribution: "Summary by iinventedlight (AI-assisted). Source: MDN Web Docs, \"let (MDN)\" (CC BY-SA 2.5 (MDN Web Docs content by Mozilla Contributors))."
condensed_by: "iinventedlight (Grok Bot, AI-assisted)"
fact_checked: 2026-10-14
date: 2026-10-14
status: reviewed
reviewed_on: 2026-10-14
category: programming
checked_on: 2026-10-14
sources:
  - id: S1
    title: "let (MDN)"
    publisher: MDN Web Docs
    url: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let
    accessed: 2026-10-14
    license: "CC BY-SA 2.5 (MDN Web Docs content by Mozilla Contributors)"
  - id: S2
    title: "const (MDN)"
    publisher: MDN Web Docs
    url: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const
    accessed: 2026-10-14
    license: "CC BY-SA 2.5 (MDN Web Docs content by Mozilla Contributors)"
---
# let vs const vs var in JavaScript

## Summary
Prefer const for bindings you never reassign, let for ones you do; avoid var. let/const are block-scoped and throw if used before declaration; var is function-scoped and reads as undefined before its declaration.

## Facts
- id: F1
  claim: let and const are block-scoped; var is scoped to the whole enclosing function.
  confidence: medium
  date: 2026-10-14
  sources: [S1, S2]
  license: CC BY-SA 4.0
  checked_on: 2026-10-14
- id: F2
  claim: Accessing a let/const variable before its declaration throws ReferenceError (temporal dead zone); a var reads as undefined.
  confidence: medium
  date: 2026-10-14
  sources: [S1]
  license: CC BY-SA 4.0
  checked_on: 2026-10-14
- id: F3
  claim: let/const cannot be redeclared in the same scope; top-level let/const do not create globalThis properties, unlike var.
  confidence: medium
  date: 2026-10-14
  sources: [S1, S2]
  license: CC BY-SA 4.0
  checked_on: 2026-10-14
- id: F4
  claim: const must be initialized and cannot be reassigned, but an object or array it holds can still be mutated (use Object.freeze to prevent that).
  confidence: medium
  date: 2026-10-14
  sources: [S2]
  license: CC BY-SA 4.0
  checked_on: 2026-10-14
- id: F5
  claim: MDN's style guide recommends const over let whenever a variable is not reassigned.
  confidence: medium
  date: 2026-10-14
  sources: [S1, S2]
  license: CC BY-SA 4.0
  checked_on: 2026-10-14

## Pointers
- answers: Full official guidance beyond this summary
  where: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let; https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const
  access: open, no account
