var variableName = '';
let ****and ****
We can take a look at both of them one by one. The variable type
let shares lots of similarities with var but unlike var it has some scope constraints. The scope is out of "scope" of this introductory video but we will explain it in great detail in a later video! The only thing that you need to know right now is that
let variableName = '';
Const is another variable type assigned to data whose value cannot and will not change throught the script.
const variableName = '';
variableName is the name of the variable which you can freely choose.
What do you think, can we name our variables literally anything?
We have a few criteria when it comes to creating variable names, also known as identifiers.
- the name of the identifier must be unique
var let = 0;
- the first character must be a letter, an underscore (_), or a dollar sign ($). Subsequent characters may be any letter or digit or an underscore or dollar sign.
To recap, there are three different ways to make (or declare) a variable:
From now on, whenever we're creating a new variable, we're going to use either the
const or the
const when variable is going to be constant and
let when we plan on changing it!
Let's move on to data types to see what kind of data can we store inside of variables!