Q1: this问题, 箭头函数与普通函数中this问题;
var a = {
show: () => {
console.log(this)
},
showA: function() {
console.log(this, 'a')
}
}
a.show()
a.showA()
运行结果:
window;
a
分析:
A1: 箭头函数中的this在声明的时候就确定了,一般函数式在运行的时候确定的;
如何确定运行时候的this,那就看是谁调用的该方法哪;
没有 xxx.funName(); 默认是window调用;