Open DamomHd opened 4 years ago
var list =[1,2,3,4,5,6,7]
function output(arr = [],deep = 2){
var resultArr = []
while(arr.length){
resultArr.push(arr.splice(0,deep))
}
return resultArr
}
output(list,2)
@群友 Webster丶提供
const arr = [1, 2, 3, 4, 5, 6, 7];
const output = (ary = [], deep = 2) => {
let itor = ary.slice(0, ary.length);
let ret = [];
while (itor.length) {
ret = [...ret, itor.splice(0, deep)]
}
return ret;
}
@群友 jjzz闹 提供
function output(arr, deep){
var res = [];
res.push(arr.splice(0,deep));
if(arr.length) res = res.concat(output(arr, deep));
return res;
}
执行output输出指定的N维数组