Suppose I have two arrays of objects
const array1 = [{
listName: 'My top 5 Sci-Fi Movies',
listCreator: 'Anon',
listItem: 'The Fifth Element'
},
{
listName: 'My top 5 Sci-Fi Movies',
listCreator: 'Anon',
listItem: 'Cube'
}]
and
const array2 = [{
listName: 'My top 5 Sci-Fi Movies',
listCreator: 'Anon',
listItem: 'The Fifth Element'
},
{
listName: 'My top 5 Sci-Fi Movies',
listCreator: 'Dude',
listItem: 'Cube'
}]
I want to able to compare the two arrays and create a new array that only has unique members of array1
, in this case
const uniqueArray = [{
listName: 'My top 5 Sci-Fi Movies',
listCreator: 'Anon',
listItem: 'Cube'
}]
I am using lodash library (but not necessary to solve this problem if not required) and I'd like to accomplish this in the fewest lines of code possible.