//一維數(shù)組變二維數(shù)組
let list = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27];? //示例
function TwoArray(list,index){
if(!Array.isArray(list) || isNaN(index)) return false;
let list_json = JSON.parse(JSON.stringify(list));
let data = [];
for(let i = 0;i<list_json.length;i++){
data.push( list_json.splice(0,list_json.length>index?index:list_json.length))
i = list_json.length>index?0:i
}
if(list_json.length>0)data.push(list_json);
return data;
}
console.log(TwoArray(list,8))