js 数组怎么去掉一级

var aa = [{a:1,b:1,c:[{aa:1},{bb:1},{cc:1}]},{a:2,b:2,c:[{dd:2},{ee:2},{ff:2}]}]

结果

console.log([{aa:1},{bb:1},{cc:1},{dd:2},{ee:2},{ff:2}])


阿波罗的战车
浏览 1233回答 2
2回答

千万里不及你

var aa = [{a:1,b:1,c:[{aa:1},{bb:1},{cc:1}]},{a:2,b:2,c:[{dd:2},{ee:2},{ff:2}]}];var arr = [];for(var a in aa)    arr.push(aa[a].c);console.log(arr);

德玛西亚99

function filter(arr){&nbsp; &nbsp; var ret = [];&nbsp; &nbsp; for(var i=0; i<arr.length; i++){&nbsp; &nbsp; &nbsp; &nbsp; if(arr[i].c){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ret = ret.concat(arr[i].c);&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp; return ret;}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript