Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

chunk an array

function __chunk(array, size) {
  let chunkArray = [];
  return function _chunk(chunk = array) {
    if (chunk.length < size) {
      return chunkArray.push(chunk) && chunkArray;
    }
    return chunkArray.push(chunk.slice(0, size)) && _chunk(chunk.slice(size));
  };
}
 
PREVIOUS NEXT
Tagged: #chunk #array
ADD COMMENT
Topic
Name
8+1 =