标签: javascript
const Car = { brand : "Honda", Speed : () => { console.log("Speed of " +this.brand + " is 120km/hr") } } Car.Speed();
此代码的输出是:
Speed of undefined is 120Km/hr
我们知道箭头函数是按词法作用域的,那么为什么this.brand返回未定义。