当前位置:网站首页>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,
边栏推荐
- 21天打卡挑战学习MySQL——《MySQL工具的使用》第一周 第二篇
- Golang第二章:程序结构
- 嵌入式系统:时钟
- for loop exercises
- websocket多线程发送消息报错TEXT_PARTIAL_WRITING--自旋锁替换synchronized独占锁的使用案例
- node连接mysql数据库报错:Client does not support authentication protocol requested by server
- [b01lers2020]Life on Mars
- [N1CTF 2018]eating_cms
- 【开源框架】国内首个通用云计算框架,任意程序都可做成云计算。
- Lift, Splat, Shoot: Encoding Images from Arbitrary Camera Rigs by Implicitly Unprojecting to 3D 论文笔记
猜你喜欢
随机推荐
Golang Chapter 2: Program Structure
全球观之地理部分
CAS:908007-17-0_Biotin-azide_Biotin azide
关于IDO预售系统开发技术讲解丨浅谈IDO预售合约系统开发原理分析
[N1CTF 2018]eating_cms
Unification of east-west and north-south communications
如何基于WPF写一款数据库文档管理工具(二)
CAS: 773888-45-2_BIOTIN ALKYNE_Biotin-alkynyl
生成器版和查看器版有什么区别?
Cisco ike2 IPSec配置
21天打卡挑战学习MySQL——《Window下安装MySql》第一周 第三篇
noip preliminary round
[MySQL Advanced] Creation and Management of Databases and Tables
【bug】汇总Elipse项目中代码中文乱码解决方法!
Pay from 0 to 1
utlis 线程池
Basic Concepts of Graphs
CAS:1260586-88-6_Biotin-C5-Azide_Biotin-C5-Azide
for loop exercises
用于流动质押和收益生成的 Web3 基础设施