当前位置:网站首页>The difference between call and apply and bind
The difference between call and apply and bind
2022-06-11 06:06:00 【No baldness】
Reference link : difference
The same thing :
call and apply and bind Are used to rebind this The direction of , And you can pass parameters .
const obj = {
name:'obj',
fun1:function (){
console.log(this.name)
}
}
const person = {
name:'person',
age:'22'
}
obj.fun1.apply(person) // person
obj.fun1.call(person) // person
obj.fun1() // obj
obj.fun1.bind(person)() // person
Of a normal function this Point to the caller for it , If not changed this Point to , So use obj.fun1() What you get is obj, Then we use apply、call、bind To change this The direction of . This is what they all have in common .
Difference :
- It's not the same .call and bind The method of passing parameters is
,separate ,apply The method of passing parameters is parameter array- for example :
fun1.call( object , Parameters 1, Parameters 2, Parameters 3...) fun1.bind( object , Parameters 1, Parameters 2, Parameters 3...)()fun1.apply( object ,[ Parameters 1, Parameters 2, Parameters 3...])
- for example :
- Different return values .bind Returns a function , Need to call... Again .call and apply Direct return function call .
边栏推荐
- NFC Development -- utility tools and development documents (IV)
- Méthode de la partie du tableau
- Set the IP address using batch
- Global case | how an airline with a history of 100 years can expand and transform to promote innovation in the aviation industry
- What is a planning BOM?
- Squid agent
- Getting started with kotlin
- NLP-D46-nlp比赛D15
- Detailed steps for installing mysql-5.6.16 64 bit green version
- Login and registration based on servlet, JSP and MySQL
猜你喜欢

FPGA面试题目笔记(三)——跨时钟域中握手信号同步的实现、任意分频、进制转换、RAM存储器等、原码反码和补码

FIFO最小深度计算的题目合集

Super details to teach you how to use Jenkins to realize automatic jar package deployment

Warmly celebrate that yeyanxiu, senior consultant of Longzhi, won the title of "atlassian Certified Expert"

Servlet

Sword finger offer 50: the first character that appears only once

Build the first power cloud platform

Using Internet of things technology to accelerate digital transformation
![Experimental report on information management and information system [information security and confidentiality] of Huazhong Agricultural University](/img/f6/e58196aeac85178f6603cea1962a6e.jpg)
Experimental report on information management and information system [information security and confidentiality] of Huazhong Agricultural University

FPGA面试题目笔记(二)——同步异步D触发器、静动态时序分析、分频设计、Retiming
随机推荐
Chapter 4 of machine learning [series] naive Bayesian model
Linux Installation redis
“All in ONE”一个平台解决所有需求,运维监控3.0时代已来
URL in flask_ for
Goodbye 2021 Hello 2022
Get the value of program exit
[metadata]linkedin datahub
FPGA面试题目笔记(二)——同步异步D触发器、静动态时序分析、分频设计、Retiming
qmake 实现QT工程pro脚本转vs解决方案
Sqli-libs post injection question 11-17 actual combat
Getting started with kotlin
Data quality: the core of data governance
Use com youth. banner. Solution to the inflateexception reported by the banner plug-in
SQLI_ LIBS range construction and 1-10get injection practice
使用Batch读取注册表
[daily exercise] 217 Duplicate element exists
Elk log system practice (V): install vector and output data to es and Clickhouse cases
Solution to slow connection speed of ojdbc under Linux system
Servlet
What is a thread pool?