I\'ve got an array of arrays, something like:
[ [1,2,3], [1,2,3], [1,2,3], ]
I would like to transpose it to get the following
Another approach by iterating the array from outside to inside and reduce the matrix by mapping inner values.
const transpose = array => array.reduce((r, a) => a.map((v, i) => [...(r[i] || []), v]), []), matrix = [[1, 2, 3], [1, 2, 3], [1, 2, 3]]; console.log(transpose(matrix));