当前位置:网站首页>How many way of calling a function?
How many way of calling a function?
2022-08-03 22:26:00 【Chinese front end】
In JavaScriptThere are 4 ways to call a function.Call to determine the function's value or "owner" object.this
- Call as a function - If a function is not called as a method, constructor, or using the
apply
,call
methods, it is called byCalled as a function.The "owner" object for this function will be thewindow
object.
//Global Scopefunction add(a,b){console.log(this);return a + b;}add(1,5); // logs the "window" object and returns 6const o = {method(callback){callback();}}o.method(function(){console.log(this); // logs the "window" object});
- Call as method - if the object's property has the value of the function,
边栏推荐
猜你喜欢
.NET6之MiniAPI(十四):跨域CORS(上)
2022-08-02 mysql/stonedb slow SQL-Q18 - memory usage surge analysis
21天打卡挑战学习MySQL——《MySQL工具的使用》第一周 第二篇
Cisco ike2 IPSec configuration
E-commerce data warehouse ODS layer-----log data loading
亿流量大考(2):开发一套高容错分布式系统
获国际权威认可 | 云扩科技入选《RPA全球市场格局报告,Q3 2022》
Boss: There are too many systems in the company, can you realize account interoperability?
《数字经济全景白皮书》金融数字用户篇 重磅发布!
noip preliminary round
随机推荐
483. Smallest Good Base
2019年10月SQL注入的两倍
HCIP第十三天
start with connect by 实现递归查询
Boss: There are too many systems in the company, can you realize account interoperability?
2022的七夕,奉上7个精美的表白代码,同时教大家快速改源码自用
2022-08-03 oracle执行慢SQL-Q17对比
中国企业构建边缘计算解决方案的最佳实践
log4j-slf4j-impl cannot be present with log4j-to-slf4j
utils 定时器
云平台建设解决方案
目标检测技术研究现状及发展趋势
pikachu Over permission
websocket多线程发送消息报错TEXT_PARTIAL_WRITING--自旋锁替换synchronized独占锁的使用案例
互联网用户账号信息管理规定今起施行:必须严打账号买卖灰产
LabVIEW code generation error 61056
老板:公司系统太多,能不能实现账号互通?
384. Shuffle an Array
HCIP BGP实验报告
[N1CTF 2018] eating_cms