Variables should be declared using “var”. When declared with var, it is a variable in the current scope (e.g local to the function). If not declared, js will search the variable in outter scopes, until it reaches the global space.
Variables declared with “var” can be deleted using 「delete myvar;」, but variable not declared with “var” cannot be deleted.
So, you should always declare variable with “var”, even for global variables.