This question already has an answer here:
I have two array of object :
the element of my table are not primitive value, but complexe objects.
array1 = [obj1,obj2,obj3,obj4]
array2 = [obj5,obj5,obj6,obj7]
I would like to compare two arrays and see of the elements of array 2 are already present in array1 then create a new array of the difference.
Any suggestion ?
ES6 This will be enough:
without includes
Plunker for you
_.difference gives you only the elements that are in the 1st array but not in the second one, nothing about the elements on the array 2 that are not in the array 1.
Is this what you want to achieve?