Skip to content

Instantly share code, notes, and snippets.

View fernandodof's full-sized avatar
🎯
Focusing

Fernando Ferreira fernandodof

🎯
Focusing
View GitHub Profile
@fernandodof
fernandodof / array.chunk.js
Last active April 7, 2016 12:21 — forked from webinista/array.chunk.js
Array.prototype.chunk: Splits an array into an array of smaller arrays containing `groupsize` members
/*
Split an array into chunks and return an array
of these chunks.
This will *not* preserve array keys.
*/
Array.prototype.chunk = function(groupsize){
var sets = [], chunks, i = 0;
chunks = this.length / groupsize;