I have an array which contains arrays of objects, that resembles this:
[{a:1}, {a:2}, {a:3}], [{b:1}, {b:2}], [{c:1}, {c:2}]
I don't know how many arrays there will be or how many objects inside them.
What I want to do is extract each object from the arrays and push them into a new array of objects where there is every possible combination of object, like this:
[
{ a:1, b:1, c:1 },
{ a:1, b:1, c:2 },
{ a:1, b:2, c:1 },
{ a:1, b:2, c:2 },
{ a:2, b:1, c:1 },
{ a:2, b:1, c:2 },
{ a:2, b:2, c:1 },
{ a:2, b:2, c:2 },
{ a:3, b:1, c:1 },
{ a:3, b:1, c:2 },
{ a:3, b:2, c:1 },
{ a:3, b:2, c:2 }
]
I've started to consider that the method might be to get the value from the a:1 object, and then loop over the others, but I'm wondering if there's an efficient pattern to solve this restructuring?