1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-29 05:42:20 +00:00

docs(decorator): 修改函数提升时代码实际执行顺序

This commit is contained in:
Careteen 2020-09-12 17:45:34 +08:00 committed by GitHub
parent 50b25c1a64
commit 6dc250f739
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -309,13 +309,13 @@ function foo() {
上面的代码,意图是执行后`counter`等于 1但是实际上结果是`counter`等于 0。因为函数提升使得实际执行的代码是下面这样。 上面的代码,意图是执行后`counter`等于 1但是实际上结果是`counter`等于 0。因为函数提升使得实际执行的代码是下面这样。
```javascript ```javascript
var counter;
var add;
@add @add
function foo() { function foo() {
} }
var counter;
var add;
counter = 0; counter = 0;
add = function () { add = function () {