当前位置:网站首页>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)); //60
2, 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']
边栏推荐
- Pytorch GPU 训练环境搭建
- ES6 deconstruction assignment - array object deconstruction and deconstruction
- 调用EasyCVR接口时视频流请求出现404,并报错SSL Error,是什么原因?
- leetcode 136. 只出现一次的数字(异或!!)
- leetcode refers to Offer 58 - II. Left Rotate String
- 友宏医疗与Actxa签署Pre-M Diabetes TM 战略合作协议
- Li Mu hands-on learning deep learning V2-BERT fine-tuning and code implementation
- Likou 59 - Spiral Matrix II - Boundary Judgment
- tRNA修饰2-甲基胞嘧啶(m2C)|tRNA修饰m2G (N2-methylguanosine)
- glusterfs 搭建使用
猜你喜欢
随机推荐
Auto.js脚本程序打包
Leetcode 16. Numerical integral power (power + fast recursive/iteration)
双线性插值公式推导及Matlab实现
tRNA-m5C转运RNA(tRNA)修饰5-甲基胞嘧啶(m5C)|tRNA修饰m1Am2A (2-methyladenosine)
有趣的opencv-记录图片二值化和相似度实现
ES6-箭头函数
Pytorch GPU 训练环境搭建
直播平台怎么搭建,针对输入框的各种组件
友宏医疗与Actxa签署Pre-M Diabetes TM 战略合作协议
3种圆形按钮悬浮和点击事件
xss.haozi练习通关详解
【飞控开发高级教程3】疯壳·开源编队无人机-定高、定点、悬停
Leetcode sword refers to Offer 15. 1 in the binary number
极验深知v2分析
leetcode 1837. K 进制表示下的各位数字总和
软件测试基本流程有哪些?权威的第三方软件检测机构推荐
YARN功能介绍、交互流程及调度策略
直播小程序源码,UI自动化中获取登录验证码
使用 ReportLab 绘制 PDF
leetcode 1837. The sum of the digits in the K-base representation