I have the following 2 arrays:
arr1 = [
{
"key1": "Value1"
},
{
"key2": "Value2"
},
{
"key3": "Test3"
},
{
"key4": "Test4"
},
{
"key5": "Test5"
},
{
"key6": "Test6"
},
{
"key7": "Test7"
}
]
And the second array is
arr2 = [
{
"key3": "Value3-changed"
},
{
"key6": "Value6-changed"
}
]
Now once I join the 2 arrays the result would be
resultArr = [
{
"key1": "Value1"
},
{
"key2": "Value2"
},
{
"key3": "Value3-changed"
},
{
"key4": "Test4"
},
{
"key5": "Test5"
},
{
"key6": "Value6-changed"
},
{
"key7": "Test7"
}
]
I saw the solution for Lodash union of arrays of objects. But as for my case, the keys are different. Any, pointers on solving this issue? I was trying to use lodash _.unionBy and then _.uniqWith but not getting the desired result.
Thanks, Andy