TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
const declaration creates a block-scoped, read-only reference to a value. It establishes an immutable binding, meaning the variable identifier cannot be reassigned to a new value, nor can it be redeclared within the same lexical scope.
Initialization Requirement
Because the binding cannot be altered after creation, aconst declaration requires an immediate initializer. Declaring a const without an assignment throws a SyntaxError during the parsing phase.
Reassignment and Redeclaration
Attempting to reassign aconst identifier throws a runtime TypeError.
SyntaxError.
Immutable Binding vs. Immutable Value
Theconst keyword guarantees an immutable binding, not an immutable value. If the assigned value is a reference type (such as an Object or an Array), the underlying data structure is not frozen. The properties or elements of that structure can be mutated, provided the variable identifier itself is not reassigned to a new memory address.
Block Scope and the Temporal Dead Zone (TDZ)
const declarations are block-scoped, meaning their visibility is limited to the nearest enclosing block { ... }.
const declarations are hoisted to the top of their block scope but remain uninitialized. The period between entering the scope and the actual lexical declaration is known as the Temporal Dead Zone (TDZ). Accessing the identifier within the TDZ throws a ReferenceError.
Global Object Context
When executed in a global script context (such as a standard<script> tag in a browser), const declarations do not create properties on the global object (e.g., window). This contrasts with var, which does append its identifier to the global environment record.
(Note: In Node.js, top-level declarations are scoped to the module wrapper by default, meaning neither var nor const creates a property on the global object.)
Master JavaScript with Deep Grasping Methodology!Learn More





