This statement tells the interpreter that a new variable x is about to be used. Variables can be assigned initial values when they are declared:
var x = 2;
In addition, multiple variables can be declared with one var statement if the variables are separated by commas:
var x, y = 2, z;
You should not use variables without first declaring them, although it is possible to do so in certain cases. Using a variable on the right-hand side of an assignment without first declaring it will result in an error.