this
说明代码输出结果
let tom = { name: 'Tom', say: function() { return ()=>{ console.log('name: ', this.name); } } } let jerry = { name: 'Jerry' } tom.say()(); tom.say().call(jerry); tom.say.call(jerry)();
输出:
name: Tom name: Tom name: Jerry
箭头函数this指向
call、apply对箭头函数的this影响
Last updated 1 year ago