In JavaScript variables are declared with the var keyword, e.g. var theName;. You may initialize the variable at the same time, thus var theName = "John";.
If you omit the var keyword and just do introduce the variables by using them they are declared as global variables. This may happen anywhere in the code, including within functions. So use the var all the time within functions to declare local variables.
In EMCAScript5 you may use the "use strict"; directive either on the global level or within a function. It it is used within a function it only applies to that function. It means that all the variables must be declared with the var keyword.




