I have 2 arrays:
var yin = [{"_id": "11111", "name": "blue"}];
var yang = [{"_id": "11111", "name": "blue"}, {"_id": "22222", "name": "red"}];
I try and filter out the following like so:
var yang = yang.filter(function(e){ return this.indexOf(e) < 0; }, yin);
For some reason, indexOf(e)
is returning -1
where I know it is the exact same data. The only thing I can think of is there is some relational (probably not the right term) data that is lying underneath that makes it seem like they are not the same since the objects are coming from completely different database sources.
Is there another method to do filter out the same data out of an array of objects that come from different sources?
I know this filter function works because if I push data using .push()
it will filter out just fine.