I just have object, that contains arrays in keys, and I need get array of string with name property. I cope to do it with flat, but probably there is better solution
const testObj = {
first: [ { name: 'Den' }, { name: 'Ben' } ],
second: [ { name: 'Ken} ]
}
Expected result:
['Den', 'Ben', 'Ken' ]
My solution:
const res = Object.keys(testObj).map(key=>{
return testObj[key].map(el=>el.name)
}).flat(1)