当前位置:网站首页>一个函数有多少种调用方式?
一个函数有多少种调用方式?
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
});- 作为方法的调用——如果对象的属性具有函数的值,
边栏推荐
- 4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
- 【云原生实用技巧】使用 skopeo 批量同步 helm chart 依赖镜像
- CAS:1797415-74-7_TAMRA-Azide-PEG-Biotin
- IO thread process -> thread synchronization mutual exclusion mechanism -> day6
- 云计算国内外发展现状
- Codeup brushing notes - simple simulation
- 483. Smallest Good Base
- 目标检测的国内外研究现状
- CAS:1192802-98-4_UV 裂解的生物素-PEG2-叠氮
- 七夕快乐!
猜你喜欢

for循环练习题

七夕快乐!

2022-08-02 mysql/stonedb slow SQL-Q18 - memory usage surge analysis

深度学习和机器学习有什么区别?

E-commerce data warehouse ODS layer-----log data loading

Teach a Man How to Fish - How to Query the Properties of Any SAP UI5 Control by Yourself Documentation and Technical Implementation Details Demo

《数字经济全景白皮书》金融数字用户篇 重磅发布!

【历史上的今天】8 月 3 日:微软研究院的创始人诞生;陌陌正式上线;苹果发布 Newton OS

CAS:908007-17-0_Biotin-azide_Biotin azide

【刷题篇】二叉树的右视图
随机推荐
113. 授人以渔 - 如何自行查询任意 SAP UI5 控件属性的文档和技术实现细节
[N1CTF 2018] eating_cms
21天打卡挑战学习MySQL—Day第一周 第一篇
如何设计 DAO 的 PoW 评判标准 并平衡不可能三角
Bytebase database schema change management tool
如何创建一个Web项目
UVa 437 - The Tower of Babylon(白书)
图的基础概念
函数,递归以及dom简单操作
2019年10月SQL注入的两倍
376. Wiggle Subsequence
With 4 years of work experience, the 5 communication methods between multi-threads can't be said, can you believe it?
2022-08-02 mysql/stonedb慢SQL-Q18-内存使用暴涨分析
Makefile
电商秒杀系统
Adobe是什么?
382. Linked List Random Node
Bytebase数据库 Schema 变更管理工具
【day6】类与对象、封装、构造方法
嵌入式系统:概述