title: Remove elements from array except particular one
body: <p>I have two arrays. First one is an array of indexes and second one is an array of objects. They look like this:</p>
  
  <pre><code>var nums = [0, 2];
  var obj = [Object_1, Object_2, Object_3];
  </code></pre>
  
  <p>In this particular case I need to remove all "<code>obj</code>" elements except <code>obj[0]</code> and <code>obj[2]</code>. So the result will look like this:</p>
  
  <pre><code>obj = [Object_2]
  </code></pre>
  
  <p>There are also may be cases when <code>nums = [0, 1, 2]</code> and <code>obj = [Object_1, Object_2, Object_3]</code>; In that case I dont need to remove any elements.</p>
  
  <p>The "<code>obj</code>" length is always greater than "nums" length.</p>
  
  <p>So I started with finding only the elements that I need to save:</p>
  
  <pre><code>nums.forEach(function(key) {
      obj.forEach(function(o, o_key) {
          if (key === o_key) {
              console.log(key, o);
              // deleting remaining elements
          }
      });
  });
  </code></pre>
  
  <p>The question: How can I remove elements that dont meets my condition? I dont need the new array, I want to modify the existing "obj" array. How can I achieve this functionality? Or should I use some another techniques?</p>