当前位置:网站首页>JS arrow function
JS arrow function
2022-06-25 04:24:00 【Robin Luo Bing】
The syntax of arrow function expression is more concise than function expression , And there's no one of its own this,arguments,super or new.target. Arrow function expressions are more suitable for places where anonymous functions are needed , And it cannot be used as a constructor .
1、 Basic grammar
(param1, param2, …, paramN) => { statements }
(param1, param2, …, paramN) => expression
// amount to :(param1, param2, …, paramN) =>{ return expression; }
// When there is only one parameter , Parentheses are optional :
(singleParam) => { statements }
singleParam => { statements }
// Functions without arguments should be written as a pair of parentheses .
() => { statements }2、 Advanced Grammar
// The bracketed function body returns the object literal expression :
params => ({foo: bar})
// The remaining parameters and default parameters are supported
(param1, param2, ...rest) => { statements }
(param1 = defaultValue1, param2, …, paramN = defaultValueN) => {
statements }
// Parameter list deconstruction is also supported
let f = ([a, b] = [1, 2], {x: c} = {x: a + b}) => a + b + c;
f(); // 6
边栏推荐
- SQL, CTE, flg case problems
- Hello CTP (V) -- CTP position calculation
- Laravel document sorting 3. CSRF protection
- 【LeetCode】148. 排序链表
- Smart wind power: operation and maintenance of digital twin 3D wind turbine intelligent equipment
- 论文阅读《LSD-SLAM: Large-Scale Direct Monocular SLAM》
- 马斯克发布人形机器人,AI对马斯克为什么意义重大?
- client-go gin的简单整合十一-Delete
- Win10 environment phpstudy2016 startup failure record
- NFT insider 63: the sandbox reached a cooperation with Time magazine, and YGG established Spain's subdao
猜你喜欢

95% of programmers fish here

UCLA | 用于黑盒优化的生成式预训练

Development of trading system (VIII) -- Construction of low delay network
Zoran community

cesium 图形标注圆形、正方形、多边形、椭圆等

How to quickly deliver high-value software

地方/园区产业规划之 “ 如何进行产业定位 ”

警惕超范围采集隐私-移动APP违规十宗罪

"Renaissance" in the digital age? The bottom digital collection makes people happy and sad

如何绘制产业招商地图
随机推荐
长沙“求才”:“下力气”与“出实招”并进,“快发展”和“慢生活”兼得
Hello CTP (IV) - CTP transaction API
Openmmlab environment configuration
【LeetCode】148. Sort linked list
Vigilance against over range collection of privacy - ten mobile app violations
讲座记录《捷联惯导解算的历史及发展》
Development of trading system (III) - risk control system
Lecture record: new application of inertial navigation - inertial measurement
NFT Insider #63:The Sandbox与时代杂志达成合作,YGG成立西班牙subDAO
Coinlist how to operate the middle lot number security tutorial
Cesium 加载显示热力图
L'épée leetcode fait référence au chemin leetcode de l'offre II 091 pour peindre la maison [planification dynamique] heroding
【Kubernetes系列】Helm的安装使用
Text keyword extraction: ansj
sql_ mode=only_ full_ group_ By's pit
Monitoring pancakeswap new token
Flutter Builder & futurebuilder components
Standing wave ratio calculation method
数字时代的“文艺复兴”?起底数字藏品,让人欢喜让人愁
虽然传统意义上的互联网早已不复存在,但这并不代表互联网早已消失不再