数据结构:
orders:
[
{
id: "DN-1155845",
xxx: false,
xxx: "Shipped",
orders:[
{ orderId:"xxx",
lps: [
{id:xxx
xxx:xxx
}
]
}
}
]
看到这个返回结构,我是想把所有的lpId组成一个数组,然后作为一个返回值,这里记录一下
var lps = orders.map(function(order){
return order.lps?.map(function(lp){
return lp.id
})
})
lps = lps.filter(Boolean).reduce(function(a,b){
return a.concat(b)
})
运行完打印就是下面这个样子