当前位置:网站首页>How to use call, bind and apply correctly
How to use call, bind and apply correctly
2022-07-22 13:22:00 【Hehe cow】
call、bind、apply Difference and use
- bind Will change this Point to And the function will not execute immediately The method of passing parameters is separated by commas
- call Will change this Point to The function will execute immediately The method of passing parameters is separated by commas
- apply Will change this Point to The function immediately points to The parameter transfer method is passed in the form of an array
let fn1 = function (a, b) {
this.name1 = ' The doll '
this.age = '40'
console.log(this, a, b)
}
let obj2 = { names: ' anaesthesia ' };
// hold obj2 Of this Point to become fn1
fn1.bind(obj2, 2, 3)(); // change this Point to Not execute
fn1.call(obj2, 2, 3); // change this Point to Automatically
fn1.apply(obj2, [2, 3]) // change this Point to Automatically The parameter transfer method is array
The results returned are the same Just pass on and Whether to execute immediately is the same
边栏推荐
- 边框动态效果实现
- JVM(9)之JVM对象创建与内存分配深度剖析
- “新能源+储能“从数字孪生开始,图扑将智慧电力做到极致
- Use of watch in projects
- [pan micro ecology] compiling_ jsp/_ login/_ upgrademessage...
- Go list 修改元素值
- Daily question-leetcode814-binary tree pruning recursion
- 智能仪器仪表行业数字化供应链管理系统:加速企业智慧供应链平台转型
- [QNX Hypervisor 2.2用户手册]8.7 虚拟I/O(VIRTIO)
- (ICLR-2021)一幅图像相当于16X16个words:大规模图像识别的Transformer
猜你喜欢
《性能之巅第2版》阅读笔记(五)--Disks监测
RecordRTC的视频录制,回放,截图,下载
Digital supply chain management system for intelligent instrument industry: accelerating the transformation of enterprise intelligent supply chain platform
Border dynamic effect implementation
ClickHouse引擎之-MaterializeMYSQL
iTOP-RK3568开发板Debian系统功能测试-有线网测试
“新能源+储能“从数字孪生开始,图扑将智慧电力做到极致
【泛微ecology】compiling _jsp/_login/_upgrademessage...
C. Doremy's IQ (greedy)
: use of class in the project
随机推荐
ACL-IJCAI-SIGIR頂級會議論文報告會(AIS 2022)筆記2:分析與可解釋性
如何将沥青高位槽液位数值无线传输至载热体记录仪监测?
如何在页面中添加地图
Huawei wireless device configuration attack detection function
Qt程序打包发布方法(使用官方提供的windeployqt工具)
(iclr-2021) an image is equivalent to 16x16 words: a transformer for large-scale image recognition
Qt5中创建及使用自定义插件遇到的一些问题
Félicitations pour la tenue réussie du Forum sur la gestion de l'innovation de produits « innovation et autonomisation » le 16 juillet
【MySQL必知必会】 存储过程 | 游标
Some methods of arrays and objects
「运维有小邓」通过审计用户活动和AD域内部变化来确保GDPR合规
SSM之简单的CRUD
JVM parent delegation mechanism
小程序项目总结
下载图片功能,全屏功能,复制功能
每日一题-LeetCode814-二叉树剪枝-递归
Clickhouse installation
Procurement control: shorten the procurement cycle, reduce costs and increase efficiency from the source
Supply chain collaborative management system of pharmaceutical machinery industry: full link digital coverage to realize the visualization of industrial supply chain
Esp8266 analog input (ADC) detection problem