I have an jsonarray A but I would like to delete the elements which satisfy a certain condition. This condition is elements which have a certain id which are contained in another array called B. They both contain the same id property.
Suppose the arrays look like this:
A =[{"id":1},{"id":2},{"id":3}]
B =[{"id":1},{"id":2}]
So the function I am trying to create would result in:
result=[{"id":3}]
I tried this but not working:
result= _.each(A, function(gl) {
return _.each(B, function(tg) {
if (tg.id != gl.id) {
return gl;
}
});
});