当前位置:网站首页>ES6--residual parameters
ES6--residual parameters
2022-08-03 20:36:00 【Hey......】
Seven, remaining parameters (new syntax)
1. The rest parameter syntax allows us to represent an indefinite number of parameters as an array.
function fn(a, b, ...c){console.log(a); //1console.log(b); //2console.log(c); //[3,4,5]}fn(1,2,3,4,5);For example (to calculate the sum):
//Calculate andconst sum = (...args) => {let total = 0;args.forEach(item => total += item)return total;}console.log(sum(10,20)); //30console.log(sum(10,20,30)); //602, rest parameters and destructuring used together
let stu = ['Xiao Ming','Xiaohong','Xiao Zhang'];let [a1, ...a2] = stu;console.log(a1); //'Xiao Ming'console.log(a2); //['Xiaohong', 'Xiao Zhang']边栏推荐
猜你喜欢
随机推荐
力扣707-设计链表——链表
用 setTimeout 来实现 setInterval
leetcode 231. 2 的幂
调用EasyCVR接口时视频流请求出现404,并报错SSL Error,是什么原因?
Go语言为任意类型添加方法
数据库定时备份winserver2012篇
ESP8266-Arduino编程实例-WS2812驱动
if _name_ == “__main__“:NameError: name ‘_name_‘ is not defined
Markdown语法
云服务器如何安全使用本地的AD/LDAP?
算法--交错字符串(Kotlin)
Leetcode sword refers to Offer 15. 1 in the binary number
ES6 introduction and let, var, const
3种圆形按钮悬浮和点击事件
微信小程序 生成跳转体验版url,可直接跳转到体验版小程序(可通过此方法测试模板消息)
async 和 await 原来这么简单
李沐动手学深度学习V2-自然语言推断与数据集SNLI和代码实现
leetcode 剑指 Offer 15. 二进制中1的个数
leetcode 136. Numbers that appear only once (XOR!!)
直播源码开发,各种常见的广告形式









