const aa = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
function transfer (aa) {
const newArr = aa[0].map((col, i) => {
return aa.map(row => {
return row[i]
})
});
return newArr;
}
const bb = transfer(aa)
简写 一行代码实现
const cc = aa[0].map((_, i) => aa.map(row => row[i]))
标签:aa,map,const,transfer,js,二维,互换,return,row
From: https://www.cnblogs.com/samsara-yx/p/16924136.html