docs(let): ES6的块级作用域使得函数可以在条件作用域内声明

This commit is contained in:
ruanyf
2016-03-05 14:35:33 +08:00
parent f50a775466
commit 1ae51bdea5
2 changed files with 39 additions and 9 deletions
+3 -8
View File
@@ -887,13 +887,6 @@ function foo() {
}
// ES5
function foo() {
setTimeout(function () {
console.log("id:", this.id);
}.bind(this), 100);
}
// 或者
function foo() {
var _this = this;
@@ -903,6 +896,8 @@ function foo() {
}
```
上面代码中,箭头函数转成ES5代码时,内部的`this`需要改为引用外部的`this`
请问下面的代码之中有几个`this`
```javascript
@@ -910,7 +905,7 @@ function foo() {
return () => {
return () => {
return () => {
console.log("id:", this.id);
console.log(`id:`, this.id);
};
};
};