loading...

re: We have 2 arrays of objects of the same class. How to substract the 1st from the 2nd, based only on one property? VIEW POST

FULL DISCUSSION
 

I'm no expert just tried.

Not tested.

Store all the various props of arrayToSubtract in an Object.

var referenceObj = {}
arrayToSubstract.forEach((item) => referenceObj[item[propertyOfReference]] = true;);

//Reference object keys should not be in arrayTotal

var outputArr = arrayTotal.filter((item) => !referenceObj[item[propertyOfReference]);

 

Interesting way to resolve the problem, it should work :)

code of conduct - report abuse