title: How to separate the difference from an array object?
body: <p>My existing array object are</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//existing object
  var existing = [
  {
  'ProviderCode':'aa',
  'msg':'....',
  },{
  'ProviderCode':'bb',
  'msg':'....',
  },{
  'ProviderCode':'cc',
  'msg':'....',
  },{
  'ProviderCode':'dd',
  'msg':'....',
  },{
  'ProviderCode':'ee',
  'msg':'....',
  }];</code></pre>
  </div>
  </div>
  
  new object I'm comparing to
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var new = [
  {
  'ProviderCode':'bb',
  'msg':'....',
  },{
  'ProviderCode':'cc',
  'msg':'....',
  },{
  'ProviderCode':'ee',
  'msg':'....',
  },{
  'ProviderCode':'ff',
  'msg':'....',
  },{
  'ProviderCode':'gg',
  'msg':'....',
  }];</code></pre>
  </div>
  </div>
  </p>
  
  <p>I would like to generate same, remove and add array based on the two array objects, I can get the same array object but not the remove and add object from the objects.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var same = [];   //bb, cc, ee   //these will be the match
  var remove = []; //aa , dd      //will be remove from existing
  var add = [];    //ff, gg       //will be consider as add
  
  //I can get the same using below:
  e.forEach(function(ev,ei,ea){
  n.forEach(function(nv,ni,na){
   if( ev.ProviderCode === nv.ProviderCode ){
    s.push({ProviderCode:ev.ProviderCode,msg:"Same, do nothing"});
      }
  });
  });
  /* //output:
  [{
  "ProviderCode": "bb",
  "msg": "Same, do nothing"
  }, {
  "ProviderCode": "cc",
  "msg": "Same, do nothing"
  }, {
  "ProviderCode": "ee",
  "msg": "Same, do nothing"
  }]
  */
  
  
  //but how do I get remove and add array object?
  
  //remove will be:
  /* //output:
  [{
  "ProviderCode": "aa",
  "msg": "removed"
  }, {
  "ProviderCode": "dd",
  "msg": "removed"
  }]
  */
  
  //add will be:
  /* //output:
  [{
  "ProviderCode": "ff",
  "msg": "added"
  }, {
  "ProviderCode": "gg",
  "msg": "added"
  }]
  */</code></pre>
  </div>
  </div>
  </p>