1. 9. 1. Variables |
|
Variables in JavaScript are defined by using the var operator (short for variable), followed by the variable name, such as: |
|
In this example, the variable test is declared and given an initialization value of "hi" (a string). |
You can also define two or more variables using the same var statement: |
var test = "hi", test2 = "hola";
|
|
Variables using the same var statement don't have to be of the same type: |
var test = "hi", age = 25;
|
|
variables in JavaScript do not require initialization: |
|