English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
JavaScript Statements and Variable Declarations
constto declare a read-only named constant.
Constants are block-scoped, very similar to usingletVariables defined by statements.
The value of a constant cannot be changed by reassignment and cannot be declared again.
You can find ourJavaScript Scope TutorialLearn more about variable scope.
const identifier = value;
const MY_AGE = 120;Test and see‹/›
The numbers in the table specify the first browser version that fully supports const statements:
Statement | |||||
const | 21 | 36 | is | 5.1 | 11 |
Parameter | Description |
---|---|
identifier | Specify the name of the constant. It can be any legal identifier. Constant names can contain letters, numbers, underscores, and dollar signs.
|
value | The value of constants. It can be any legal expression. |
JavaScript Version: | ECMAScript 1 |
---|
JavaScript Tutorial:JavaScript Variables
JavaScript Tutorial:JavaScript Scope