what's the cleanest way to flatten an array of objects that have this type interface:
Interface {
Item: Item,
SubItems: Array<Item>
}
example of an array:
myArray = [
{Item: {id: "bla1"}, SubItems: [{id: "bla2"}, {id: "bla3"}, {id: "bla4"}]},
{Item: {id: "bla5"}, SubItems: [{id: "bla6"}, {id: "bla7"}, {id: "bla8"}]}
]
the end result should be a single array of all these same type objects, and ordered like this:
first object -> Item -> SubItems
second object -> Item -> SubItems
so in my example I should have this:
flattenedArray = [{id: "bla1"}, {id: "bla2"}, {id: "bla3"}, {id: "bla4"}, ...]