流浪のwolf

卷帝

导航

介绍this指向问题

 this是js底层定义的变量,代表了代码的指向环境

a 函数的this是window

b 方法的this是调用的对象

c 构造函数和原型对象上的方法的this指向实例化对象

d 箭头函数不会自己创建this指向,会沿用作用域的上一层this指向

e 注册事件的this指向事件源

f setInterval 和 setTimeout 函数的this指向window

严格模式下this是undefined

posted on 2022-08-18 07:00  流浪のwolf  阅读(16)  评论(0编辑  收藏  举报