📜  将数组分块 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:21.888000             🧑  作者: Mango

代码示例2
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));
  };
}