const all = [{
'name': 'first',
'attributes': [{
'name': 'attr1'
}]
}, {
'name': 'second',
'attributes': [{
'name': 'attr2'
}]
}]
const res = all.reduce((acc, el) => {
return acc + el.attributes
}, [])
console.log(res)
I need get next
result => [{'name':'attr1'}, {'name':'attr2'}]
What is the best way do it, it can be not only reduce.
flatMap, though, would work