Javascript Array eachSlice(size, callback)
Array.prototype.eachSlice = function (size, callback){ for (var i = 0, l = this.length; i < l; i += size){ callback.call(this, this.slice(i, i + size)); }//from w ww.j a va 2 s .co m };