1
sezina Feb 27, 2014
没有。一个函数内的所有变量的声明都会被提前到前面。
|
2
jsonline Feb 27, 2014 via Android
不存在不存在不存在
|
3
Blueshit Feb 27, 2014 try
{...} catch(e) {...} 这个 e 只作用于 catch 语句块 |
4
serenader Feb 27, 2014
没有。
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 Feb 27, 2014
有,新的ES里有: let
for(let i = 0 ; i < xxx; i++) { ... } |
6
muzuiget Feb 27, 2014
有,ES6 标准里才有,现在只有 Firefox 支持。
|
7
muzuiget Feb 27, 2014
|
8
zhulinpinyu Feb 28, 2014
目前只有函数级作用域,没有块级作用域。
|
9
hussion Feb 28, 2014
ES6以前木有,但是可以通过闭包实现块级作用域;ES6可以用let实现块级作用域
|
10
xuyifei Mar 1, 2014
块级作用域确实是js的一个坑
|
11
nil Mar 1, 2014
多用函数,js里面函数能给你其他主流语言提供的一切功能~
|
12
g0thic Mar 24, 2014
没有块级作用域,不过可以模仿块级作用域
|