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}])
2 回答
千万里不及你
TA贡献1784条经验 获得超9个赞
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
TA贡献1770条经验 获得超3个赞
function filter(arr){
var ret = [];
for(var i=0; i<arr.length; i++){
if(arr[i].c){
ret = ret.concat(arr[i].c);
}
}
return ret;
}
添加回答
举报
0/150
提交
取消