Created
November 4, 2015 17:19
-
-
Save paveleremin/8d2b3590c04aedf0ea79 to your computer and use it in GitHub Desktop.
Array chunk
This file contains hidden or 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(len) { | |
var chunks = []; | |
for (var i = 0, l = this.length; i < l; i += len) { | |
chunks.push(this.slice(i, i + len)); | |
} | |
return chunks; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment