title: Return the index of object that exist in both array when comparing Javascript
body: <p>------Edited---------------</p>
  
  <p>I have 2 arrays of objects A, B</p>
  
  <pre><code>var a = [{id:1},{id:2},{id:3},{id:4},{id:5}];
  var b = [{id:1},{id:2},{id:3}];
  </code></pre>
  
  <p>I want to delete object which are both in A and in B</p>
  
  <pre><code>//after the operation
   a = [{id:1},{id:2},{id:3}];
  </code></pre>
  
  <p>I thought in order to do it, I need to get the index of them in A to use A.splice() but I just cannot wrap my head around how I can do it.</p>
  
  <p>This is the code I use to get the objects itself from
  <a href="https://stackoverflow.com/questions/21987909/difference-between-two-array-of-objects-in-javascript">Difference between two array of objects in JavaScript</a></p>
  
  <pre><code> var onlyInA = A.filter(function(current){
      return res.nodes.filter(function(current_b){
          return current_b._id == current._id
      }).length == 0
  </code></pre>