Skip to content

Instantly share code, notes, and snippets.

@obenjiro
Last active August 29, 2015 14:06
Show Gist options
  • Save obenjiro/888352066919f87a52f8 to your computer and use it in GitHub Desktop.
Save obenjiro/888352066919f87a52f8 to your computer and use it in GitHub Desktop.
Shortest Chunk implementation
//chunk
function chunk(arr, n) {
var result = [];
while(arr.length) {
result.push(arr.splice(0,n))
}
return result;
}
//chunk - obfuscated (72 chars)
function chunk(n,u,r){for(r=[];n.length;)r.push(n.splice(0,u))
return r}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment