I have an Array like this
[
{
name: "A",
job: ["1", "2"]
},
{
name: "B",
job: ["2"]
},
{
name: "C",
job: []
}
]
How do i flatten it into something like this using lodash.
[
{
name: "A",
job: ["1"]
},
{
name: "A",
job: ["2"]
},
{
name: "B",
job: ["2"]
},
{
name: "C",
job: []
}
]
The only solution coming to my mind is to iterate recursively.
Thanks.
lodashoverVanillaJSis because if in future the nesting has sub nests thenlodashis better capable of handling it. At least it's what i thought based on normallodashcapabilities.