I'm trying to remove objects from an array of object using a delta data i'm getting from server. I'm using underscore in my project.
Is there a straight forward way to do this, rather going with looping and assigning ?
Main Array
var input = [
{name: "AAA", id: 845,status:1},
{name: "BBB", id: 839,status:1},
{name: "CCC", id: 854,status:1}
];
Tobe Removed
var deltadata = [
{name: "AAA", id: 845,status:0},
{name: "BBB", id: 839,status:0}
];
Expected output
var finaldata = [
{name: "CCC", id: 854,status:1}
]
Array.prototype.filterwith a predicate that performs a.indexOfon the other array.inputthat do not appear indeltadata- either based on structural equality (in which case you'd.map(JSON.stringify)before performing a .indexOf and stringify the value too, or reference equality - in which case you'd use a simple.indexOf