es6 合并数组

2019-03-15  本文已影响0人  遥啊遥啊遥啊

let books = ['1', '2', '3'];

let books1 = ['4', '5'];

let book2 = ['6', '7']

let allbooks = books1.concat(books, book2)

let allbooks1 = [...allbooks,...book2]

// 将数组里面的值显示出来(es6写法...)

console.log(...allbooks,...book2)

console.log(allbooks1)

打印结果:4 5 1 2 3 6 7 6 7

[ '4', '5', '1', '2', '3', '6', '7', '6', '7' ]

注意:有顺序之分

上一篇 下一篇

猜你喜欢

热点阅读