介绍
扩展运算符能将[数组]转换位逗号分隔的[参数序列]
声明一个数组
const boby =['张倩','李旺','赵茜']
声明一个函数
function chuan(){ console.log(arguments); } chuan(...boby)
应用
1.数组的合并
const kuaizi =['王太利','肖央']; const babb =['焊丝里','花花']; const klok =kuaizi.concat(fenghuang); const klok = ['...kuaizi,...babb']; console.log(klok);
变成数组(
const klok = ['...kuaizi,...babb'];
)
2.数组的克隆
浅拷贝
const szh = ['E','G','M']; const kel =[...szh]; console.log(kel);
3.将伪数组转化为真数组
const divs = document.querySelectorAll('div') const divArr = [...divs] console.log(divArr);
标签:...,const,log,扩展,kuaizi,运算符,数组,klok From: https://www.cnblogs.com/0722tian/p/17107727.html