数组合并(数组元素为基本类型)

4年以前  |  阅读数:272 次  |  编程语言:JavaScript 
const arr1 =[1, 2, 3, 4].concat([5, 6]) //[1,2,3,4,5,6]
const arr2 =[...[1, 2, 3, 4],...[4, 5]] //[1,2,3,4,5,6]
const arrA = [1, 2], arrB = [3, 4]
const arr3 =Array.prototype.push.apply(arrA, arrB)//arrA值为[1,2,3,4]

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8