Skip to content

Instantly share code, notes, and snippets.

@karthickvkumar
Created June 20, 2017 06:11
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 karthickvkumar/33e8f0fb84cbd62c714813251f6ae010 to your computer and use it in GitHub Desktop.
Save karthickvkumar/33e8f0fb84cbd62c714813251f6ae010 to your computer and use it in GitHub Desktop.
Chunk array into equals
Array.prototype.chunk = function ( n ) {
if ( !this.length ) {
return [];
}
return [ this.slice( 0, n ) ].concat( this.slice(n).chunk(n) );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment