如何将多个数组合并成一个数组

如何将多个数组合并成一个数组[编程语言教程]

如何将多个数组合并成一个数组

concat:连接两个或多个数组

 

例:arr1连接arr2

var arr1 = [‘q‘,‘w‘]
var arr2 = [‘e‘,‘r‘]
var arr3 = [1,2]

console.log(arr1.concat(arr2))

输出:["q", "w", "e", "r"]

 

例:arr1连接arr3

var arr1 = [‘q‘,‘w‘]
var arr2 = [‘e‘,‘r‘]
var arr3 = [1,2]

console.log(arr1.concat(arr3))

输出:["q", "w", 1, 2]

 

 

例:arr1连接arr2,arr3

var arr1 = [‘q‘,‘w‘]
var arr2 = [‘e‘,‘r‘]
var arr3 = [1,2]

console.log(arr1.concat(arr2,arr3))

输出:["q", "w", "e", "r", 1, 2]

如何将多个数组合并成一个数组

原文:https://www.cnblogs.com/maoyi/p/13676120.html