← Back to topic library
Dev MaxxingBeginnerJavaScript60 sec
JavaScript variable
A JavaScript variable is a named storage location that holds a value, which can be referenced and, depending on how it was declared, reassigned later.
What matters
Whether a variable can be reassigned, and what part of the code can see it, depends on how it is declared, which affects how predictable a program's behavior is.
Example
Declaring 'let count = 0;' creates a variable that can later be reassigned, such as with 'count = count + 1;'.
Common misconception
A variable declared with 'const' is not necessarily fully unchangeable; if it holds an object, the object's contents can still be modified even though the variable can't be reassigned.
Recall question
What can differ between two variables that both hold the same current value?
Keywords and related concepts
JavaScript variabledeclarationassignmentjavascript function