当前位置:网站首页>[JS] the problem pointed by this
[JS] the problem pointed by this
2022-07-25 21:34:00 【Small size helps you move forward】
Every time the parser calls the function, it passes an implicit parameter to the function , The implicit parameter is this,this It points to an object , This object we call function execution Context object , Depending on how the function is called ,this Will point to different objects .
- Call... As a function ,this It's always window
function fun(){
console.log(this)
}
// Call... As a function ,this yes window
fun();
- When called as a method ,this Is the object of the called method
function fun(){
console.log(this)
console.log(this.name)
}
var name = " Overall name attribute "
var obj = {
name:" La la la ",
sayName:fun,
}
var obj2 = {
name:" Lulu, Lulu ",
sayName:fun,
}
// Call... As a method ,this yes obj
obj.sayName();
obj.sayName();
fun();
I am the editor of this article kk, encounter Bug Need help , Welcome to add wx:xmzl1988 , remarks "csdn Blog “, Tips: This is a non free service ;
边栏推荐
- strcpy()
- 人脸与关键点检测:YOLO5Face实战
- Please give an example of how to optimize MySQL index (sqlserver index optimization)
- Fusing and degrading Sentinel
- 作为测试,如何理解线程同步异步
- Pychart automatically enters the test mode when running the program
- Apple estimates that iPhone will give up the Chinese market, and the Chinese industrial chain needs to consider living a hard life
- Mysql8.0 MHA to achieve high availability "MHA"
- Sum of two numbers and three numbers
- CNN structural design skills: taking into account speed accuracy and engineering implementation
猜你喜欢

Basic method of black box (function) test

Jmeter分布式压测

Cesium polygon gradient texture (canvas)

I'm also drunk. Eureka delayed registration and this pit!

2022 latest examination questions and answers of eight members (standard staff) of Shanghai Architecture

字节一面:TCP 和 UDP 可以使用同一个端口吗?
QT | learn about QT creator by creating a simple project

Reading the pointpillar code of openpcdet -- Part 3: Calculation of loss function

Stm3 (cubeide) lighting experiment
![[fiddlertx plug-in] use Fiddler to capture the package Tencent classroom video download (unable to capture the package solution)](/img/de/7a288ee8e6001235d4869c10503932.png)
[fiddlertx plug-in] use Fiddler to capture the package Tencent classroom video download (unable to capture the package solution)
随机推荐
Cesium polygon gradient texture (canvas)
Airtest解决“自动装包”过程中需要输入密码的问题(同适用于随机弹框处理)
When MySQL imports data, it has been changed to CSV utf8 file and the file name is English. Why does it still fail to import
ES6---4个强大运算符(??、??=、?.、?:)
ONEFLOW V0.8.0 officially released
黑盒(功能)测试基本方法
Oracle RAC RMAN backup error ora-19501 ora-15081
测试用例和缺陷报告模板
Beisen Holdings' IPO: a total loss of 4.115 billion yuan in three years, and a total of 2.84 billion yuan in the previous nine rounds of financing
Please give an example of how to optimize MySQL index (sqlserver index optimization)
一道golang中关于接口和实现的面试题
919. Complete binary tree inserter: simple BFS application problem
PE格式: 分析IatHook并实现
[database] index
数据库sql语句练习题「建议收藏」
ES6 -- Deconstruction assignment
Apache Shenyu admin authentication bypass vulnerability (cve-2021-37580) analysis and protection measures
Array of arm disassembly
Face and key point detection: yolo5face practice
Kali modify the update source (it is not safe to update with this source)