Created
May 4, 2017 09:19
-
-
Save tatomyr/518ddd982b182929c0e3969cf23f8cea to your computer and use it in GitHub Desktop.
One-line JavaScript array transpose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[0, 1], [2, 3], [4, 5]].reduce((prev, item) => item.map((_, i) => [...(prev[i] || []), item[i]]), []); // [[0, 2, 4], [1, 3, 5]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment