let count = 10;
let countObj = {
count: 1,
add() {
function setCount1() {
console.log(this); //window
console.log(this.count); //undefined
}
let setCount2 = () => {
console.log(this); //countObj
console.log(this.count); //1
}
setCount1();
setCount2();
}
}
countObj.add();
```
案例--let、箭头函数
最新推荐文章于 2023-12-27 06:51:32 发布