当前位置:网站首页>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']边栏推荐
猜你喜欢
随机推荐
wordpress建立数据库连接时出错
不知道这4种缓存模式,敢说懂缓存吗?
Markdown语法
xss.haozi练习通关详解
系统运维系列 之CSV文件读取时内容中包含逗号的处理方法
倒计时2天,“文化数字化战略新型基础设施暨文化艺术链生态建设发布会”启幕在即
简单又有效的基本折线图制作方法
化算力为战力:宁夏中卫的数字化转型启示录
Advantages and Disadvantages of Blind and Buried Via PCB Stacked Via Design
一种能有效缓解环境噪声对音频质量干扰的方案
通关剑指 Offer——剑指 Offer II 009. 乘积小于 K 的子数组
CLIP论文解读
Android build error: Plugin with id ‘kotlin-android‘ not found.
Auto.js实现朋友圈自动点赞
头条服务端一面经典10道面试题解析
盲埋孔PCB叠孔设计的利与弊
leetcode 072. 求平方根
EasyCVR平台海康摄像头语音对讲功能配置的3个注意事项
若依集成browscap读取浏览器用户代理
在树莓派上搭建属于自己的网页(3)









