当前位置:网站首页>一个函数有多少种调用方式?
一个函数有多少种调用方式?
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
});
- 作为方法的调用——如果对象的属性具有函数的值,
边栏推荐
- 如何基于WPF写一款数据库文档管理工具(二)
- .NET6之MiniAPI(十四):跨域CORS(上)
- Zilliz 2023 秋季校园招聘正式启动!
- 【刷题篇】二叉树的右视图
- IO thread process -> thread synchronization mutual exclusion mechanism -> day6
- CAS:153162-70-0_N-BOC-6-Biotinamidohexylamine
- Internet user account information management regulations come into effect today: must crack down on account trading and gray products
- Golang第一章:入门
- Boss: There are too many systems in the company, can you realize account interoperability?
- 113. Teach a Man how to fish - How to query the documentation and technical implementation details of any SAP UI5 control property by yourself
猜你喜欢
Flutter 桌面探索 | 自定义可拖拽导航栏
一些思考:腾讯股价为何持续都低
【历史上的今天】8 月 3 日:微软研究院的创始人诞生;陌陌正式上线;苹果发布 Newton OS
Data_web(八)mysql增量同步到mongodb
DO280管理和监控OpenShift平台--资源限制
嵌入式系统:时钟
YOLO之父宣布退出CV界,坦言无法忽视自己工作带来的负面影响
113. Teach a Man how to fish - How to query the documentation and technical implementation details of any SAP UI5 control property by yourself
CAS:1192802-98-4_UV 裂解的生物素-PEG2-叠氮
2022-08-02 mysql/stonedb慢SQL-Q18-内存使用暴涨分析
随机推荐
Unification of east-west and north-south communications
382. Linked List Random Node
golang写的存储引擎,基于b+树,mmap
授人以渔 - 如何自行查询任意 SAP UI5 控件属性的文档和技术实现细节试读版
Embedded systems: overview
易观分析:2022年Q2中国网络零售B2C市场交易规模达23444.7亿元
[N1CTF 2018] eating_cms
决策树、GBDT、XGBOOST树的可视化
【历史上的今天】8 月 3 日:微软研究院的创始人诞生;陌陌正式上线;苹果发布 Newton OS
Bytebase database schema change management tool
Golang Chapter 2: Program Structure
Kubernetes入门到精通-Operator 模式
Conditional Statements for Shell Programming
E-commerce data warehouse ODS layer-----log data loading
【MySQL进阶】数据库与表的创建和管理
一文带你了解软件测试是干什么的?薪资高不高?0基础怎么学?
Lift, Splat, Shoot: Encoding Images from Arbitrary Camera Rigs by Implicitly Unprojecting to 3D 论文笔记
Flink--Join以及Flink函数
Teach a Man How to Fish - How to Query the Properties of Any SAP UI5 Control by Yourself Documentation and Technical Implementation Details Demo
for循环练习题