当前位置:网站首页>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);
边栏推荐
- MySQL advanced (Advanced SQL statement)
- [secretly kill little partner pytorch20 days] - [day4] - [example of time series data modeling process]
- ECS deployment web project
- 数据读写:Unity中基于C#脚本实现数据读写功能
- [ansible series] fundamentals 02 module debug
- 雲服務器部署 Web 項目
- After getting these performance test decomposition operations, your test path will be more smooth
- [road of system analyst] collection of wrong topics in Project Management Chapter
- Summation of basic exercise sequence of test questions
- MySQL log management, data backup and recovery
猜你喜欢

VLAN access mode

MySQL日志管理、数据备份、恢复

Solitidy - fallback 回退函数 - 2种触发执行方式

Create priority queue

AI大模型落地大考,浪潮交出了怎样的答卷?

UE4_ Editor development: highlight the UI making method according to the assets dragged by the mouse (1)

PC viewing WiFi password

Mysql database learning notes - foreign keys, table connections, subqueries, and indexes for MySQL multi table queries

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

What kind of answer has Inspur given in the big AI model landing test?
随机推荐
Tornado frame foundation
Leetcode search insert location
Luogup2756 pilot pairing scheme problem (maximum flow)
Answer sheet for online assignment of "motor and drive" of Xijiao 21 autumn (IV) [standard answer]
观察者模式、状态模式在实际工作中的使用
MySQL advanced (Advanced SQL statement)
领导:谁再用 Redis 过期监听实现关闭订单,立马滚蛋!
[openstack]-01- basic introduction
Turn off automatic outlining in Visual Studio - turning off automatic outlining in Visual Studio
[Alibaba cloud] student growth plan answers
网络基础知识
09- [istio] istio service entry
What do you think of the deleted chat records? How to restore the deleted chat records on wechat?
On line assignment of financial cost management in the 22nd spring of Western Polytechnic University [Full Score answer]
Xi'an Jiaotong 21st autumn online expansion resources of online trade and marketing (III) [standard answer]
Switch to software testing and report to the training class for 3 months. It's a high paying job. Is it reliable?
Online assignment of C language program design in the 22nd spring of Western Polytechnic University
Transfer the token on the matic-erc20 network to the matic polygon
10-【istio】istio Sidecar
Mysql database learning notes - foreign keys, table connections, subqueries, and indexes for MySQL multi table queries