当前位置:网站首页>js的call()和apply()
js的call()和apply()
2022-06-25 04:00:00 【刘家奕_】
call()和apply()
-这两个方法都是函数对象的方法,需要通过函数对象来调用
-当对函数调用call()和apply()都会调用函数执行
-在调用call()和apply()可以将一个对象指定为第一个参数
此时这个对象将会成为函数执行时的this
- call()方法可以将实参在对象之后依次传递
- apply()方法需要将实参封装到一个数组中统一传递
- this的情况:
1.以函数形式调用时,this永远都是window
2.以方法的形式调用时,this是调用方法的对象
3.以构造函数的形式调用时,this是新创建的那个对象
4.使用call和apply调用时,this是指定的那个对象
边栏推荐
- mongodb集群
- Introduction to intstream API
- 【LeetCode】22. bracket-generating
- CTF_ Variable coverage in web:php
- 2021.8.29 notes: register, bit operation, pointer, structure
- NFT insider 63: the sandbox reached a cooperation with Time magazine, and YGG established Spain's subdao
- GBASE 8s活锁、死锁问题的解决
- 关于TCP连接三次握手的详细总结
- [kubernetes series] installation and use of Helm
- GBASE 8S内存管理
猜你喜欢

GBASE 8s 索引B+树

讲座记录《多种空间大地测量技术的数据处理方法和应用》

i. Max development board learning record

GBASE 8s 索引R树

Office macro virus bounce shell experiment

记录小知识点

Laravel document sorting 4. Controller

Anaconda安装+TensorFlow安装+Keras安装+numpy安装(包含镜像和版本信息兼容问题)

"How to carry out industrial positioning" in local / Park industrial planning

Watch out for the stolen face! So many risks of face recognition used every day?
随机推荐
GBASE 8s的包
UCLA | generative pre training for black box optimization
Musk released humanoid robot. Why is AI significant to musk?
SQL注入详解
"Renaissance" in the digital age? The bottom digital collection makes people happy and sad
A-table mouse over the display hand, the current line can be clicked
CTF_ Web: Advanced questions of attack and defense world expert zone WP (19-21)
Laravel document sorting 11. System architecture
Anaconda installation +tensorflow installation +keras installation +numpy installation (including image and version information compatibility issues)
GBASE 8s存储过程语法结构
Laravel document sorting 6. Response
SQL injection details
LeetCode 剑指Offer II 091 粉刷房子[动态规划] HERODING的LeetCode之路
Upgrade cmake
Unit test coverage
Lecture record: new application of inertial navigation - inertial measurement
CTF_ Web: basic 12 questions WP of attack and defense world novice zone
BSC smart contract dividend mainstream currency | including marketing wallet | deflation | reflow | dividend free token | available for direct deployment
i. Max development board learning record
Error 1062 is reported during MySQL insertion, but I do not have this field.