Created
November 25, 2018 22:32
-
-
Save chrdek/16ec75a7c3803038a7aaa13907f828a5 to your computer and use it in GitHub Desktop.
Transform onedim arrays into twodim..
This file contains hidden or 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
var a = [0,1,2,3,4], | |
b = [5,6,7,8,9]; | |
Array.prototype.zip = function (arr) { | |
return this.map(function (e, i) { | |
return [e, arr[i]]; | |
}) | |
}; | |
//Usage: a.zip(b) = [[0,5], [1,6], [2,7], [3,8], [4,9]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment