有关this的指向问题

this 的指向有哪些?
1 、普通函数中的 this 指向 window
2 、定时器中的 this 指向 window
3 、箭头函数没有 this, 它的 this 指向取决于外部环境、
4 、事件中的 this 指向事件的调用者
5 、 构造函数中 this 和原型对象中的 this, 都是指向构造函数 new 出来实例对象 6 、类 class 中的 this 指向由 constructor 构造器 new 出来的实例对象
7 、自调用函数中的 this 指向 window

猜你喜欢

转载自blog.csdn.net/qq_59020839/article/details/127353945