Skip to content

Instantly share code, notes, and snippets.

@tatomyr
Created May 4, 2017 09:19
Show Gist options
  • Save tatomyr/518ddd982b182929c0e3969cf23f8cea to your computer and use it in GitHub Desktop.
Save tatomyr/518ddd982b182929c0e3969cf23f8cea to your computer and use it in GitHub Desktop.
One-line JavaScript array transpose
[[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