Declares a variable.
Use the var statement to declare variables. These variables can be assigned values at declaration or later in your script.
The first time a variable appears in your script constitutes its declaration.
You can declare a variable without using the var keyword and assign a value to it. This is known as an implicit declaration, and it is not recommended. An implicit declaration gives the variable global scope. When you declare a variable at the procedure level, though, you typically do not want it to have global scope. To avoid giving the variable global scope, you must use the var keyword in your variable declaration.
Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information.