What Are JavaScript variables?
We use variables to store information. The type of information depends on what we are building. If we are building a game, maybe we need to store the play score, position etc. But the fact is that all programs need a way to store data. It is important to remember that variables are containers for values, and are not the actual values themselves.
Code example
Let us get our feet wet, and look at the variable assignment below.
let fullName = "Ola Nordmann"
The let keyword tells the JavaScript code interpreter that we are
going to define a new block scoped
variable. fullName is
called the identifier of the variable. It is this identifier we refer
to in order to later on get access to the contained value. The =
symbol signifies an assignment, meaning we want to give the left side
of the symbol the value of the right side. In this case it is a string
(text) value.