title: Javascript - How to delete items from an array at given indices
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12311467/strip-remove-values-in-array-at-certain-indices">Strip/remove values in array at certain indices</a>  </p>
  </blockquote>
  
  
  
  <p>How do I remove a set of elements from an array at given indices using Javascript.</p>
  
  <p>Say I have an index array:</p>
  
  <p><code>var indices = [0, 1, 3]</code>. </p>
  
  <p>I want to remove elements from another array at these given <code>indices</code>.  That other array happens to be:</p>
  
  <p><code>var cars = ["Cow", "Dog", "Ferrari", "Monkey", "Ford"]</code>. </p>
  
  <p>So, after deletion I want "Cow", "Dog", "Monkey" to be removed from <code>cars</code> array</p>
  
  <p>I have tried the <code>splice</code> way:</p>
  
  <pre><code>for(var i = 0; i &lt; indices.length; i++){
     cars.splice(indices[i], 1);
  }
  </code></pre>
  
  <p>But this code happens to change the indices of the <code>cars</code> array every time an item is spliced!</p>