Created
February 23, 2009 17:04
-
-
Save ioseb/69058 to your computer and use it in GitHub Desktop.
JavaScript array chunk function
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
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