取出二维数组中的第一列的数据组成新的的二维数组
[
["154771", "166172", "162127", "166577", "166125", "163573"],
["415721", "406873", "414609", "429625", "410276", "434955"]
]
变为想要的样子
想把这个二维数组中第一个数组的元素和第二个元素取出组成一个新的二维数组,后面依次
var arr= [
["154771", "166172", "162127", "166577", "166125", "163573"],
["415721", "406873", "414609", "429625", "410276", "434955"]
]
var arry=[]
for (let i = 0; i < arr[0].length; i++) {
for (let j = 0; j < arr.length; j++) {
arry.push(arr[j][i])
}
}
function group(array, subGroupLength) {
let index = 0;
let newArray = [];
while (index < array.length) {
newArray.push(array.slice(index, (index += subGroupLength)));
}
return newArray;
}
console.log(arr)
console.log(group(arry, arr.length))