-8

I have 2 object arrays a1 and a2 with ID and Name properties. 1. I want to compare a1 and a2 and delete whatever is there in a1 which is not in a2. 2. Add whatever is in a2 but not in a1.

I want to store the delete and add results in 2 different arrays.

  • 5
    This post doesn't show any research or effort on your part to solve your issues. – dfundako May 17 '17 at 13:49
  • no research effort, -1 also @Oen44 I don't think this is the way.. you will see this for yourself of course, I guess :) – Vitaliy Terziev May 17 '17 at 13:51
  • You might want to take a look at [how to ask a question](http://stackoverflow.com/help/how-to-ask). Even if someone would want to do this work for you, your description is too vague. Ex: What decides if two objects are equal? – Ozgar May 17 '17 at 13:56
  • Ozgar - I have mentioned 2 elements Id and Name. – Nitin Shekhawat May 18 '17 at 14:36

1 Answers1

0

You can use filter to manage your array.

var a1_filtered = a.filter(function(current_a){
    return b.filter(function(current_b){
       [your code...]  
});

You can find the full example here: https://stackoverflow.com/a/21988185/3345789

don't forget to search please :)

Community
  • 1
  • 1
allema_s
  • 132
  • 1
  • 6