Skip to content

Instantly share code, notes, and snippets.

@duffy-walsh
Created November 17, 2013 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duffy-walsh/7517886 to your computer and use it in GitHub Desktop.
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
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