I have two arrays:
var one = [
Object { _id="53c907016b7536a18b0001ab", title="..." },
Object { _id="53c90942b879875e2b0001ec", title="..." }
]
var two = [
Object { _id="53c907016b7536a18b0001ab", title="..." }
]
I am looking to find the difference, i.e.
[
Object { _id="53c90942b879875e2b0001ec", title="..." }
]
Using underscore.js, I tried:
var difference = _.difference( one, two );
but that returns the whole one
array, rather than the difference.
I assume the problem is that my arrays contain objects, rather than primitives. If that is the case, how can I tell underscore to use the values of _id
for the comparison?