[size=medium]Note that unlike C, C++, and Java, JavaScript does not have lock-level scope. All variables declared in a function, no matter where they are declared, are defined throughout the function.
it is good programming practice to place all your variable declarations together at the start of any function.
[/size]
it is good programming practice to place all your variable declarations together at the start of any function.
[/size]
本文介绍了JavaScript中变量的作用域特性,对比C、C++和Java等语言,指出JavaScript没有锁级作用域。所有在函数内声明的变量,在整个函数范围内都是可见的。良好的编程实践建议将所有变量声明放在函数的开始部分。
729

被折叠的 条评论
为什么被折叠?



