Lets say I have two objects, for example
const obj1 = {
a: [{asd1: 1}, {asd2: 2}, {asd3: 3}]
}
const obj2 = {
a: [{asd4: 4}],
b: [{a: "asd"}, {b: "asd"}]
}
I have to merge the two objects having a result like this
obj3 = {
a: [{asd1: 1}, {asd2: 2}, {asd3: 3}, {asd4: 4}]
b: [{a: "asd"}, {b: "asd"}]
}
What would be the most effective way to accomplish this?
2
Answers
Here is a reference for you,but not elegant,waiting to see others answer
What if a property is an object in both objects? Then a recursion is in place.