// [1, 2, 3, 4, 5, 6].chunk(2); -> [[1, 2], [3, 4], [5, 6]]
if (typeof Array.prototype.chunk === 'undefined') {
Array.prototype.chunk = function (size) {
for (var x, i = 0, c = -1, l = this.length, n = []; i < l; i++) {
(x = i % size) ? n[c][x] = this[i] : n[++c] = [this[i]];
}
return n;
};
}
Array.prototype.chunk = function (size) {
for (var x, i = 0, c = -1, l = this.length, n = []; i < l; i++) {
(x = i % size) ? n[c][x] = this[i] : n[++c] = [this[i]];
}
return n;
};
}