I'm sure this has been answered many times, but I guess I either don't know how to ask the question, or I'm not understanding how to apply concepts from simple array reduce/flatten situations into slightly more complex object arrays.
Say I have an array of objects 'Item' that has 2 properties, 'Name' and 'SubItems,' which is itself an array of objects with a 'Name' property.
Conceptually, something like this...
[
{ Name: 'Obj1', SubItems: [{Name: 'Sub1'}, {Name: 'Sub2'}, {Name: 'Sub'3}] },
{ Name: 'Obj2', SubItems: [{Name: 'Sub4'}, {Name: 'Sub5'}] }
]
What's a good way to "flatten" or "select many" of the SubItems, preferably just using javascript? Essentially, I want a single array of SubItems:
[
{Name: 'Sub1'},
{Name: 'Sub2'},
{Name: 'Sub3'},
{Name: 'Sub4'},
{Name: 'Sub5'}
]