Skip to content

Instantly share code, notes, and snippets.

@ioseb
Created February 23, 2009 17:04
Show Gist options
  • Save ioseb/69058 to your computer and use it in GitHub Desktop.
Save ioseb/69058 to your computer and use it in GitHub Desktop.
JavaScript array chunk function
function arrayChunk(array, size) {
var start = 0, result = [], chunk = [];
while((chunk = array.slice(start, start += size)).length) {
result.push(chunk);
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment