this的指向,箭头函数的this

this的指向,箭头函数的this

①当this所在函数是事件处理函数时,this代表事件源

②当this所在函数是构造函数时,this代表new出来的对象

③当this所在函数是类的方法时,this代表调用方法的对象。

④当this所在函数没有所属对象,this代表window对象。
箭头函数根本没有自己的this,它内部的this就是外层代码块的this

猜你喜欢

转载自blog.csdn.net/wen15191038073/article/details/120222336