当前位置:网站首页>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
边栏推荐
- Watch out for the stolen face! So many risks of face recognition used every day?
- 微信小程序中的列表渲染
- 95% 程序员都在这里摸鱼……
- Openmmlab environment configuration
- Error 1062 is reported during MySQL insertion, but I do not have this field.
- Laravel document sorting 3. CSRF protection
- How to use ide to automatically sign and debug Hongmeng application
- Standing wave ratio calculation method
- PHP code audit 2 - these functions must be known and understood
- Simple integration of client go gin -update
猜你喜欢
Coinlist queuing tutorial to improve the winning rate
Hello CTP (III) - CTP quotation API
讲座记录《捷联惯导解算的历史及发展》
长沙“求才”:“下力气”与“出实招”并进,“快发展”和“慢生活”兼得
Development of trading system (VIII) -- Construction of low delay network
Serious PHP defects can lead to rce attacks on QNAP NAS devices
Error 1062 is reported during MySQL insertion, but I do not have this field.
Hello CTP (II) -- Introduction to CTP
Nodejs 通过Heidisql连接mysql出现ER_BAD_DB_ERROR: Unknown database 'my_db_books'
Flutter FittedBox组件
随机推荐
WMS仓储管理系统的使用价值,你知道多少
"Renaissance" in the digital age? The bottom digital collection makes people happy and sad
DAP data scheduling function improvement description
Laravel document sorting 10. Request life cycle
A-table mouse over the display hand, the current line can be clicked
DAP数据调度功能完善说明
Lecture record: new application of inertial navigation - inertial measurement
Standing wave ratio calculation method
Read lsd-slam: large scale direct monolithic slam
Smart wind power: operation and maintenance of digital twin 3D wind turbine intelligent equipment
Hello CTP (IV) - CTP transaction API
SEO的5大关键指标:排名+流量+会话+停留时长+跳出率
代表多样性的彩色 NFT 系列上线 The Sandbox 市场平台
Mathematical analysis_ Notes_ Chapter 3: limits
Leetcode points to the leetcode road of offering II 091 house painting [dynamic planning] heroding
Development of trading system (VI) -- HFT high frequency trading
Laravel document sorting 7. View
5 key indicators of SEO: ranking + traffic + session + length of stay + bounce rate
Sourcetree pulls the code and prompts to fill in authentic, but the configuration cannot change the user
Windows 2003 64 bit system PHP running error: 1% is not a valid Win32 Application