当前位置:网站首页>ES6扩展运算符(...)
ES6扩展运算符(...)
2022-06-30 05:58:00 【SignalFire】
1、分割数组
let arr = [1,2,3,4,5];
console.log(...arr);
2、连接数组
let arr = [1,2,3,4];
let arr2 = [5,6];
arr.push(...arr2);
console.log(arr);
其他方式
let arr = [1,2,3,4];
let arr2 = [5,6];
// arr.push(...arr2);
Array.prototype.push.apply(arr,arr2);
console.log(arr);
3、函数参数解析
function fn(...args){
console.log(args);
}
fn(1,2,3,4,5);
function fn(a,b,...args){
console.log(a,b,args);
}
fn(1,2,3,4,5,6);
边栏推荐
- Basic operations of C language
- 24、 I / O device model (serial port / keyboard / disk / printer / bus / interrupt controller /dma and GPU)
- Dao -- a beautiful new world?
- AI大模型落地大考,浪潮交出了怎样的答卷?
- Cisco VXLAN配置
- Turn off automatic outlining in Visual Studio - turning off automatic outlining in Visual Studio
- 接口中方法详解
- Shenzhou ares tx6 boot logo modification tutorial
- UE4_ Editor UMG close window cannot destroy UMG immediately
- Ultra simple STM32 RTC alarm clock configuration
猜你喜欢

MySQL storage system

Dao -- a beautiful new world?

Use of OpenCL thread algebra library viennacl
![[GPU] basic operation of GPU (I)](/img/ce/0ca8c63525038fea64c40aabd17fc6.jpg)
[GPU] basic operation of GPU (I)
![[deep learning] data segmentation](/img/16/798881bbee66faa2fb8d9396155010.jpg)
[deep learning] data segmentation

PC viewing WiFi password

Strlen and sizeof, array length and string length, don't be silly

The average salary of software testing in 2022 has been released. Have you been averaged?

Do you know how to show the health code in only 2 steps

Tornado frame foundation
随机推荐
Today, Ali came out with 35K. It's really sandpaper that wiped my ass. it showed me my hand
Implementation of property management system with ssm+ wechat applet
如何制作CSR(Certificate Signing Request)文件?
重构之美:当多线程批处理任务挑起大梁 - 万能脚手架
09- [istio] istio service entry
[openstack]-01- basic introduction
[OSPF] comparison between rip and OSPF
Codeforces Round #390 (Div. 2) D. Fedor and coupons
Using lazy < t > in C # to realize singleton mode in WPF
ES6数组遍历与ES5数组遍历
OSPF - authentication and load balancing summary (including configuration commands)
UE4_ Editor development: highlight the UI making method according to the assets dragged by the mouse (1)
AI大模型落地大考,浪潮交出了怎样的答卷?
领导:谁再用 Redis 过期监听实现关闭订单,立马滚蛋!
PC viewing WiFi password
Summation of basic exercise sequence of test questions
Gestion des utilisateurs de la base de données MySQL
There is a group of students' score {99, 85, 82, 63, 60}. To add a student's score, insert it into the score sequence and keep the descending order
English语法_形容词/副词3级-最高级
[ansible series] fundamentals -01