Open this example in the interactive library
Source code
const rows = [
[1, 2, 3],
[4, 5, 6],
];
console.log(rows[0].map((_, i) => rows.map((r) => r[i])));
Sample output
[ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]

Open this example in the interactive library
const rows = [
[1, 2, 3],
[4, 5, 6],
];
console.log(rows[0].map((_, i) => rows.map((r) => r[i])));
[ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]