/ Published in: JavaScript
URL: http://jsfromhell.com/array/chunk
Breaks an array into pieces. Created: 2006.06.04
Expand |
Embed | Plain Text
/* ************************************** * chunk Function v1.0 * * Autor: Carlos R. L. Rodrigues * ************************************** */ function chunk(a, s){ for(var x, i = 0, c = -1, l = a.length, n = []; i < l; i++) (x = i % s) ? n[c][x] = a[i] : n[++c] = [a[i]]; return n; }
You need to login to post a comment.
