Skip to content

Instantly share code, notes, and snippets.

@crossRT
Created December 26, 2017 02:37
Show Gist options
  • Save crossRT/946421f314f36525d8dd1868d3ca87d1 to your computer and use it in GitHub Desktop.
Save crossRT/946421f314f36525d8dd1868d3ca87d1 to your computer and use it in GitHub Desktop.
Plain JavaScript chunk
function chunk(array, size) {
return array.reduce(function (res, item, index) {
if (index % size === 0) {
res.push([]);
}
res[res.length - 1].push(item);
return res;
}, []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment