2024年07月19日 建站教程
es6语法中如何实现合并数组,下面web建站小编给大家简单介绍一下扩展运算符…的具体使用代码!
合并数组代码介绍:
const a = [1, 2, 3, 4]; const b = [3, 4, 5]; const c = [6, 7, 8, 9]; console.log([...a, ...b, ...c]); //(11) [1, 2, 3, 4, 3, 4, 5, 6, 7, 8, 9] console.log([...c, ...a, ...b]); //(11) [6, 7, 8, 9, 1, 2, 3, 4, 3, 4, 5] console.log([99, ...a, 24, ...b, ...c]); //(13) [99, 1, 2, 3, 4, 24, 3, 4, 5, 6, 7, 8, 9]
本文链接:http://so.lmcjl.com/news/8772/