网站首页 > 知识剖析 正文
1.指向的是事件源
2. 读取对象中的方法时,此时的this指向当前对象
3. 未开启严格模式,全局下面的函数调用中的this指向window
4. 开启严格模式,全局下函数调用中的this指向undefined
5. 定时任务中的this指向window,以setinterval为例
6. 箭头函数中的this,指向的是箭头函数所在作用域的上一级作用域中的this
7. call、apply和bind等方法可以改变this指向的问题,以call方法为例
未调用call方法 obj中的c方法指向的this是obj对象
调用call方法并传入了window对象,此时obj中的c方法指向的this就变为window对象,bind 和 apply同理,另额外补充一句call方法和apply会立即执行该函数,bind方法不会立即执行,需要接受返回值,重新调用
猜你喜欢
- 2024-11-11 windows时间同步服务器设置 win10时间同步服务器设置
- 2024-11-11 javaScript 使用定时器 js实现定时器功能
- 2024-11-11 如何理解JavaScript定时器的4种写法「带面试题讲解」
- 2024-11-11 如何设置Windows系统 Internet时间的同步周期
- 2024-11-11 setInterval、setTimeout和requestAnimationFrame
- 2024-11-11 JavaScript 定时器和延时器 js定时器缺点
- 2024-11-11 手把手教你制作智能桌宠(小可爱哦!)
- 2024-11-11 setInterval()和setTimeout()区别及清除定时器
- 2024-11-11 第37节 计时器setTimeout和setInterval
- 最近发表
- 标签列表
-
- xml (46)
- css animation (57)
- array_slice (60)
- htmlspecialchars (54)
- position: absolute (54)
- datediff函数 (47)
- array_pop (49)
- jsmap (52)
- toggleclass (43)
- console.time (63)
- .sql (41)
- ahref (40)
- js json.parse (59)
- html复选框 (60)
- css 透明 (44)
- css 颜色 (47)
- php replace (41)
- css nth-child (48)
- min-height (40)
- xml schema (44)
- css 最后一个元素 (46)
- location.origin (44)
- table border (49)
- html tr (40)
- video controls (49)