I had a lists of duplicate array of String and array of object. I want to find the property into one particular object of array uniquely without duplication of array object. If can done in lodash library, it would be awesome.
const arr1 = ['test@email', 'test2@email']
const arr2 = [{ id: 1, email: 'test@email' }]
Expected result
['test2@email']
this is what I done so far
By turning arr1 into object frist so I can compare with arr2
const emailLists = _.map(arr, function (item) {
console.log(item)
return { email: item }
})
then merge them to together and used uniq to remove duplicates
const merge = _.unionBy(array1, array2, 'email')
const result _.uniq(merge, 'email');
I think it still not a good process and not clean