把数组分割为二维数组

在这里插入图片描述
附代码

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

猜你喜欢

转载自blog.csdn.net/qq_39517820/article/details/106196681