I'm looking for a way to flatten an array within an object using JavaScript, preferably ES6. I'm not sure if "flattening" is the correct term here, but I just want a solution to achieve this transformation.
Currently, I have this structure:
{
id: "123",
name: "test",
history: [
{
id: "456",
name: "test2"
},
{
id: "789",
name: "test3"
}
]
}
And I want to convert it to:
{
id: "123",
name: "test"
},
{
id: "456",
name: "test2"
},
{
id: "789",
name: "test3"
}
The original object includes a "history" property specific to that object. Any suggestions on how to approach this?