Created
June 20, 2017 06:11
-
-
Save karthickvkumar/33e8f0fb84cbd62c714813251f6ae010 to your computer and use it in GitHub Desktop.
Chunk array into equals
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
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