The var statement is used to declare a variable, and outside of a function its use is optional. While a variable can be declared simply by assigning it a value, it is good practice to use var as there are two cases in functions where it is necessary:

   If a global variable of the same name exists.

   If recursive or multiple functions use variables of the same name.
var i;
You can also declare more than one variable and, optionally, assign values at the same time:
var i = 0, x, max = 57;

Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information