1
sezina 2014 年 2 月 27 日
没有。一个函数内的所有变量的声明都会被提前到前面。
|
2
jsonline 2014 年 2 月 27 日 via Android
不存在不存在不存在
|
3
Blueshit 2014 年 2 月 27 日 try
{...} catch(e) {...} 这个 e 只作用于 catch 语句块 |
4
serenader 2014 年 2 月 27 日
没有。
Unlike most programming languages, JavaScript does not have block-level scope (variables scoped to surrounding curly brackets); instead, JavaScript has function-level scope. Variables declared within a function are local variables and are only accessible within that function or by functions inside that function. 摘自 http://javascriptissexy.com/javascript-variable-scope-and-hoisting-explained/ |
5
normanzb 2014 年 2 月 27 日
有,新的ES里有: let
for(let i = 0 ; i < xxx; i++) { ... } |
6
muzuiget 2014 年 2 月 27 日
有,ES6 标准里才有,现在只有 Firefox 支持。
|
7
muzuiget 2014 年 2 月 27 日
|
8
zhulinpinyu 2014 年 2 月 28 日
目前只有函数级作用域,没有块级作用域。
|
9
hussion 2014 年 2 月 28 日
ES6以前木有,但是可以通过闭包实现块级作用域;ES6可以用let实现块级作用域
|
10
xuyifei 2014 年 3 月 1 日
块级作用域确实是js的一个坑
|
11
nil 2014 年 3 月 1 日
多用函数,js里面函数能给你其他主流语言提供的一切功能~
|
12
g0thic 2014 年 3 月 24 日
没有块级作用域,不过可以模仿块级作用域
|