当前位置:网站首页>this指向问题
this指向问题
2022-07-31 05:11:00 【抱抱旋旋子】
this的指向在函数定义的时候是确定不了的,只有函数执行的时候才能确定this到底指向谁,一般情况下this的最终指向的是那个调用它的对象
现阶段,我们先了解一下几个this指向
1.全局作用域或者普通函数中this指向全局对象window(注意定时器里面的this指向window )
在定时器方法的第一个参数的函数中,this指向的也是window对象
2.在方法中,谁调用的方法,this就指向谁
3.构造函数中的this指向的是新创建的实例
边栏推荐
- 字符串的新增方法
- [Elastic-Job] Overview of Distributed Scheduling Tasks
- Error: Cannot find module ‘D:\Application\nodejs\node_modules\npm\bin\npm-cli.js‘
- Getting to know regular expressions
- 安装Multisim出现 No software will be installed or removed解决方法
- sqlmap注入教程 常用指令
- Fragmented NFT (Fractional NFT)
- leetcode-1833. 雪糕的最大数量(排序+贪心)
- 正则表达式基础知识
- 5 methods of MySQL paging query
猜你喜欢
随机推荐
Fragmented NFT (Fractional NFT)
npm WARN config global `--global`, `--local` are deprecated. Use `--location解决方案
通信原理——纠错编码 | 汉明码(海明码)手算详解
mysql启动报错The server quit without updating PID file几种解决办法
sqlmap injection tutorial common commands
Linux中mysql密码修改方法(亲测可用)
Regular Expression Basics
NFT:数字所有权的核心
[Ubuntu20.04 installs MySQL and MySQL-workbench visualization tool]
Object,多态 1(第八天)
What is the difference between NFT and digital collection?
C language tutorial (3) - if and loop
13 【代理配置 插槽】
MySQL压缩包方式安装,傻瓜式教学
Error: Cannot find module ‘D:\Application\nodejs\node_modules\npm\bin\npm-cli.js‘
leetcode-每日一题1252. 奇数值单元格的数目(模拟优化)
Getting to know regular expressions
What is GameFi?
永恒之蓝漏洞复现
Build vulhub vulnerability shooting range on kali