Splicing objects from an array Javascript
<p>I am trying to remove an object from an array if a particular value for a key matches a given string:</p>

<p>Example data: </p>

<pre><code>array = [{_id: "abc", test: "123"}, 
         {_id: "def", test: "123"},
         {_id: "ghi", test: "123"}];
</code></pre>

<p>Here is my loop: </p>

<pre><code>for (var i = 0; i &lt; array.length; i++) {
    var x = "123"
    if (array[i].test == x) {
       array.splice(i, 1)
    }
}
</code></pre>

<p>This should return an empty array but it's leaving one object in the array (the last one) and I've got no clue why.</p>