扩展运算符 扩展运算符1【...】扩展运算符是能将数组转换为逗号分隔的参数序列 声明一个数组 1const boys=['a','b','c']; 声明一个函数 123456function chunwan(){ console.log(arguments);}chunwan(boys);//Array(3),length:1chunwan(...boys);//length:3 ['a,','b','c']chunwan('a','b','c')//上面等价于这个 扩展运算符的应用1.数组的合并 12345const kuaizi=['王太利','肖央'];const fenghuang=['曾毅','玲花'];//const fantasyapple=kuaizi.concat(fenghuang);const fantasyapple=[...kuaizi,...fenghuang];console.log(fantasyapple);//[] 2.数组的克隆 123const flowers=['E','G','M'];const grass=[...flowers];//['E','G','M'];console.log(grass); 3.将伪数组转换为真正的数组 1234const divs = document.querySelectorAll('div');const divArr=[...divs];console.log(divs);//对象console.log(divArr)//数组[div,div,div] ES6及以上 扩展运算符 https://blog-theta-ten.vercel.app/2021/06/25/扩展运算符/ 作者 Chen 发布于 2021年6月25日 许可协议 OJ系统-邮箱验证码 上一篇 postman报错404 下一篇 Please enable JavaScript to view the comments