Variables in JavaScript are declared using the var keyword (variable).
You can also use the var keyword to give multiple values to a variable.
In addition, unlike java, javascript can store different data types in the same variable. For example
In addition, javascript can be used without declaring variables, for example:
When JavaScript encounters an undeclared variable, it will automatically create a global variable for it. For good usage habits, variables should be declared, which is good for work.
In addition, variable declaration should follow the following rules,
The first letter of a variable can be an uppercase or lowercase English letter, an underscore or the dollar "$" symbol
The remaining letters can be underscores, uppercase and lowercase letters, any numbers, or the dollar sign
The name of a variable cannot be a reserved word or keyword
Here are some legal variable names
The following are some illegal variable names
The above is the entire content of this article. It is all very basic knowledge. I hope you will like it.