I am trying to combine two arrays of objects without using the method unionBy
from lodash.
I am currently working fine on the following code:
var array1 = [
{ a: 1, b: 'first'},
{ a: 2, b: 'second'}
];
var array2 = [
{ a: 3, b: 'third'},
{ a: 1, b: 'fourth'}
];
var array3 = __.unionBy(array2, array1, 'a');
It is output:
[
{
"a": 3,
"b": "third"
},
{
"a": 1,
"b": "fourth"
},
{
"a": 2,
"b": "second"
}
]
This is the desired result, but I cannot use it unionBy
in my current working environment, so I am looking for a result that uses either native JS, or other methods of lodash 3.6.0 or lower.
source
share