File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -381,7 +381,9 @@ function f() { console.log('I am outside!'); }
381
381
}());
382
382
```
383
383
384
- 很显然,这种行为差异会对老代码产生很大影响。为了减轻因此产生的不兼容问题,ES6在[ 附录B] ( http://www.ecma-international.org/ecma-262/6.0/index.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics ) 里面规定,浏览器的实现可以不遵守上面的规定,有自己的[ 行为方式] ( http://stackoverflow.com/questions/31419897/what-are-the-precise-semantics-of-block-level-functions-in-es6 ) 。
384
+ 但是,如果你真的在 ES6 浏览器中运行一下上面的代码,是会报错的,这是为什么呢?
385
+
386
+ 原来,ES6 改变了块级作用域内声明的函数的处理规则,显然会对老代码产生很大影响。为了减轻因此产生的不兼容问题,ES6在[ 附录B] ( http://www.ecma-international.org/ecma-262/6.0/index.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics ) 里面规定,浏览器的实现可以不遵守上面的规定,有自己的[ 行为方式] ( http://stackoverflow.com/questions/31419897/what-are-the-precise-semantics-of-block-level-functions-in-es6 ) 。
385
387
386
388
- 允许在块级作用域内声明函数。
387
389
- 函数声明类似于` var ` ,即会提升到全局作用域或函数作用域的头部。
You can’t perform that action at this time.
0 commit comments