js将数组拆分成规定长度的二维数组

resolveArr(array, len) {
      let index = 0;
      let newArray = [];
      while (index < array.length) {
        newArray.push(array.slice(index, (index += len)));
      }
      return newArray;
    }

 

posted @ 2023-03-28 22:40  _曾经沧海难为水  阅读(20)  评论(0编辑  收藏  举报