Skip to main content

Language fundamentals

JavaScript Variables: let, const, Scope, and Values

A variable is a binding to a value. Distinguishing reassignment from object mutation makes const, scope, and state changes much easier to reason about.

JavaScriptbeginner4 min readJavaScript fundamentals

Learning overview

Estimated time
4 minutes
Difficulty
Beginner
Prerequisites
No prior experience required
Learning outcome
Explain javascript using a clear mental model · Apply javascript in practical JavaScript work
Last updated
July 18, 2026

Separate bindings from values

A declaration creates a binding in a scope. The binding can refer to a primitive value or an object. Const prevents that binding from being reassigned, but properties of a referenced object can still change.

bindings.js
const course = { title: "JavaScript" };
course.title = "Modern JavaScript"; // object mutation is allowed

// course = { title: "CSS" }; // TypeError: assignment to const binding

let progress = 0;
progress = 1; // intentional reassignment

Use lexical block scope

Let and const belong to the nearest block. Code can access outer bindings according to where functions and blocks are written, which is lexical scope. Before initialization, a binding exists in the temporal dead zone and cannot be read.

Choose declarations from intent

Use const by default because it communicates that the binding will remain stable. Use let when reassignment is part of the algorithm, such as a counter or accumulated result. Avoid var in new code unless its function-scoped behavior is specifically required.

  • Give bindings names that describe domain meaning
  • Keep scope as small as practical
  • Do not reuse one variable for unrelated meanings
  • Trace reassignment separately from nested mutation

Frequently asked questions

Does const make a JavaScript object immutable?

No. It prevents reassignment of the binding. Use disciplined immutable updates, Object.freeze for shallow runtime protection, or other tools when object mutation must be restricted.

What is the temporal dead zone?

It is the interval between entering a scope and initializing a let, const, or class binding, during which accessing that binding throws a ReferenceError.

Topic graph

A taxonomy-generated path through this subject.

  1. JavaScript
  2. JavaScript fundamentals
  3. javascript
  4. variables
  5. scope
  6. fundamentals
  7. What Is JavaScript in Programming?
  8. Learn JavaScript: From Fundamentals to Web Applications
  9. JavaScript Tutorial: Build a Filterable Task List

Recommended automatically from shared technologies, topics, intent, and difficulty.

Hand-picked companion pages that deepen this topic.

Your next steps

Continue learning

  1. 1glossaryWhat Is JavaScript in Programming?
  2. 2guidesLearn JavaScript: From Fundamentals to Web Applications
  3. 3guidesJavaScript Tutorial: Build a Filterable Task List
  4. 4cheatsheetsJavaScript Cheatsheet: Syntax, Collections, DOM, Async