Created
November 17, 2013 20:29
-
-
Save duffy-walsh/7517886 to your computer and use it in GitHub Desktop.
Array chunk prototype function from stackoverflow users ninjagecko and blazemonger;
Take an array and return an array of its elements chunked into chunkSize
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
Array.prototype.chunk = function(chunkSize) { | |
var R = []; | |
for (var i=0; i<this.length; i+=chunkSize) | |
R.push(this.slice(i,i+chunkSize)); | |
return R; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment