当前位置:网站首页>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);
边栏推荐
- 电脑查看WiFi使用密码
- What do you think of the deleted chat records? How to restore the deleted chat records on wechat?
- [GPU] basic operation
- Tornado frame foundation
- CompletableFuture从了解到精通,你想知道的这里都有
- Simple use of qlistview of QT (including source code + comments)
- 拼多多店铺搜索相关问题,为什么新品上架搜索不到
- 24、 I / O device model (serial port / keyboard / disk / printer / bus / interrupt controller /dma and GPU)
- 超简单 STM32 RTC闹钟 时钟配置
- Force deduction exercise -- deleting repeated items in ordered sequence 1.0
猜你喜欢

Cisco vxlan configuration

86. separate linked list
![[ansible series] fundamentals -01](/img/b4/1f3284338c75acb5259849a45bbfbe.jpg)
[ansible series] fundamentals -01

At the beginning of 2022, people who are ready to change jobs should pay attention to

从零开发 stylelint规则(插件)

English grammar_ Adjective / adverb Level 3 - superlative

动态规划--怪盗基德的滑翔翼

强烈推荐十几款IDEA开发必备的插件

雲服務器部署 Web 項目

Basic operations of C language
随机推荐
Did you know that WPS can turn on eye protection mode?
Simple use of qlistview of QT (including source code + comments)
[deep learning] data segmentation
【板栗糖GIS】global mapper—如何把栅格的高程值赋予给点
[GPU] basic operation
【LeetCode】236. Nearest common ancestor of binary tree
Dao -- a beautiful new world?
Luogup2756 pilot pairing scheme problem (maximum flow)
Intelligent question - horse racing question
ES6数组遍历与ES5数组遍历
拼多多店铺搜索相关问题,为什么新品上架搜索不到
SHELL
Sound net, debout dans le "sol" de l'IOT
Gestion des utilisateurs de la base de données MySQL
Huxiaochun came to fengshu electronics to sign a strategic cooperation agreement with Zoomlion
飞升:基于中文分词器IK-2种自定义热词分词器构建方式showcase & 排坑showtime
[ansible series] fundamentals -01
Xctf attack and defense world crypto advanced area
Title: enter two positive integers m and N to find their maximum common divisor and minimum common multiple
Detailed explanation of issues related to SSL certificate renewal