By Martin Schaeferle | July 23, 2012
var count = 0; <program code> count = "Don"; <more program code> count = false <yet more code> count = "The Duke of Windsor";
var count = 0 minMsgID = 32629, lastName = "Kiely";
TIP: In ECMAScript 5/Strict mode, it is an error to assign a value to an undeclared variable. But in older versions of the standard, and in ECMAScript 5/Default mode, the variable is declared as a property of the global object as described above. It is legal and generally harmless to declare a variable more than once with the var statement, although it takes extra typing and clutters up your code. If a later, redundant var statement also initializes the variable, it acts as a simple assignment statement. No matter how many times you declare a variable within its scope, you'll have only a single instance of the variable.