About the Var Statement
The var statement is used to declare variables. This statement can be used to declare a single variable using the following format:
You can use var to declare more than one variable at a time using the following format:
It can also be used with initializers to declare and initialize variables in a single statement:
Following are some examples:
If you do not specify an initializer, the variable is set equal to null:
is the same as:
You can also use var inside for and for/in statements as follows: