I\'m new in JavaScript programming and I have two object arrays that have the following structure:
myFirstObjArray = [{foo: 1, bar: 1}, {foo: 3, bar: 3}, {fo
You could filter by look up.
const unique = a => o => !a.some(({ foo }) => o.foo === foo);
var first = [{foo: 1, bar: 1}, {foo: 3, bar: 3}, {foo: 4, bar: 5}],
second = [{foo: 2}, {foo: 4}, {foo: 5}],
uniqueFirst = first.filter(unique(second)),
uniqueSecond = second.filter(unique(first));
console.log(uniqueFirst);
console.log(uniqueSecond);
.as-console-wrapper { max-height: 100% !important; top: 0; }