首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

宣言变量时是否使用var的不同

2012-11-23 
声明变量时是否使用var的不同是否使用var声明变量,结果是不同的,使用var声明的变量是局部的,反之是全局的!

声明变量时是否使用var的不同

是否使用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.

热点排行