当前位置:网站首页>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']边栏推荐
猜你喜欢
随机推荐
15年软件架构师经验总结:在ML领域,初学者踩过的五个坑
微信小程序 生成跳转体验版url,可直接跳转到体验版小程序(可通过此方法测试模板消息)
Leetcode 16. Numerical integral power (power + fast recursive/iteration)
svg+js订单确认按钮动画js特效
leetcode 448. Find All Numbers Disappeared in an Array 找到所有数组中消失的数字(简单)
数学之美 第六章——信息的度量和作用
How can a cloud server safely use local AD/LDAP?
独立站卖家在哪些平台做社交媒体营销效果最好?
leetcode 1837. K 进制表示下的各位数字总和
LeetCode 899. 有序队列
RNA核糖核酸修饰RNA-HiLyte FluorTM 405荧光染料|RNA-HiLyte FluorTM 405
glusterfs build and use
伪标签汇总
leetcode 16.01. 交换数字(不使用临时变量交换2个数的值)
NAACL 2022 | 具有元重加权的鲁棒自增强命名实体识别技术
双线性插值公式推导及Matlab实现
Leetcode sword refers to Offer 15. 1 in the binary number
转运RNA(tRNA)甲基化修饰7-甲基胞嘧啶(m7C)|tRNA-m7G
tRNA-m5C转运RNA(tRNA)修饰5-甲基胞嘧啶(m5C)|tRNA修饰m1Am2A (2-methyladenosine)
glusterfs 搭建使用









