Created
October 6, 2018 23:50
-
-
Save danielpradilla/67f34c55a23c3a725677194a1dce19a0 to your computer and use it in GitHub Desktop.
transpose-in-javascript
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
/** | |
* http://www.codesuck.com/2012/02/transpose-javascript-array-in-one-line.html | |
*/ | |
function transpose(a) { | |
return Object.keys(a[0]).map(function (c) { | |
return a.map(function (r) { | |
return r[c]; | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment