function flattern(list,depth=0){ var res = []; for(var item of list){ if(Array.isArray(item) && depth>0){ //深度 var child = flattern(item,depth-1); res = res.concat(child) }else{ res.push(item); } } return res; }