是否使用var声明变量,结果是不同的,使用var声明的变量是局部的,反之是全局的!
For example, when we use the keyword var, the JavaScript will create a variable in the current (or local) scope of the code block you are adding the code to. If we skip the var keyword, the variable will still be created, but in the global scope of your program, which means it would be visible from anywhere in the (.js) file. Again, try to avoid using globals.