当前位置:网站首页>一个函数有多少种调用方式?
一个函数有多少种调用方式?
2022-08-03 22:22:00 【紫微前端】
在JavaScript中有 4 种方法可以调用函数。调用确定该函数的值或“所有者”对象。this
- 作为函数调用- 如果函数没有作为方法、构造函数或使用
apply,call方法调用,则它被作为函数调用。此函数的“所有者”对象将是该window对象。
//Global Scope
function add(a,b){
console.log(this);
return a + b;
}
add(1,5); // logs the "window" object and returns 6
const o = {
method(callback){
callback();
}
}
o.method(function (){
console.log(this); // logs the "window" object
});- 作为方法的调用——如果对象的属性具有函数的值,
边栏推荐
- [MySQL Advanced] Creation and Management of Databases and Tables
- Shell编程的条件语句
- noip初赛
- 【MySQL进阶】数据库与表的创建和管理
- E-commerce data warehouse ODS layer-----log data loading
- LabVIEW代码生成错误 61056
- 物联网新零售模式,引领购物新潮流
- 如何创建一个Web项目
- Nine ways to teach you to read the file path in the resources directory
- 网络基础学习系列四(网络层,数据链路层和一些其他重要协议或技术)
猜你喜欢
![[b01lers2020]Life on Mars](/img/d0/d5c9b7224542c8843ce29adc7ef713.png)
[b01lers2020]Life on Mars

CAS: 773888-45-2_BIOTIN ALKYNE_生物素-炔基

Bytebase database schema change management tool

CAS: 1192802-98-4 _uv cracking of biotin - PEG2 - azide

亿流量大考(2):开发一套高容错分布式系统

如何创建一个Web项目

Cisco ike2 IPSec配置

CAS:153162-70-0_N-BOC-6-Biotinamidohexylamine

noip preliminary round

CAS:153162-70-0_N-BOC-6-生物素酰氨基己胺
随机推荐
CAS:908007-17-0_Biotin-azide_Biotin azide
CAS:122567-66-2_DSPE-生物素_DSPE-Biotin
Codeup brushing notes - simple simulation
IO线程进程->线程同步互斥机制->day6
2022-08-02 mysql/stonedb slow SQL-Q18 - memory usage surge analysis
Kubernetes入门到精通-Operator 模式
21天打卡挑战学习MySQL——《MySQL工具的使用》第一周 第二篇
东西向和南北向通信的统一
如何设计 DAO 的 PoW 评判标准 并平衡不可能三角
start with connect by implements recursive query
CAS:1620523-64-9_Azide-SS-biotin_biotin-disulfide-azide
483. Smallest Good Base
for loop exercises
Zilliz 2023 秋季校园招聘正式启动!
21天打卡挑战学习MySQL—Day第一周 第一篇
Golang第二章:程序结构
PowerMockup 4.3.4::::Crack
UVa 1025 - A Spy in the Metro (White Book)
HCIP第十四天
Makefile