我有两个数组要合并,但是在搜索中我只能找到Array.concat
。
let a = [1,2,3,4,5]
let b = [6,7,8,9,10]
如何结合这些以创建以下内容?
let combine = [
[1,6],
[2,7],
[3,8],
[4,9],
[5,10]
]
如果两个数组的长度相同,则可以执行以下操作:
let a = [1,2,3,4,5]
let b = [6,7,8,9,10]
let combine = a.map((e, i) => [e, b[i]]);
console.log(combine);