So I have 2 arrays. The first array contains the full list of my objects and the second array contains objects that I got from the first array.
My question is how can I get objects from the first array not present in the second array? So I have tried something like this, in which I create a temporary array. This is my code:
var violators = CSR.ViolatorDetails.violators.slice();
$.each(collectedFrom, function(idx, obj){
var obj = Main.Objects.get_object(CSR.ViolatorDetails.violators,obj.violator_id,'violator_id');
//the object is in CRS.ViolatorDetails.violators
if(obj != null){
var i = CSR.ViolatorDetails.violators.indexOf(obj);
console.log(i);
if(i >= 0){
console.log('Removing');
violators.slice(i,1);
}
}
});
CSR.ViolatorDetails.violators contains the full list of my object. collectedFrom contains objects that I get from the first array. violators is the temporary array I have created.
Your responses would be greatly appreciated.
You can suggest if I can change my approach or just have to change something within my code.
Thanks.