Javascript for...in sometimes goes through unexisted attribute
<p>Some times when I call methods of this object I got "Oops" error because "i" refers to unexisted attribute. How its possible?</p>

<pre><code>m.derp();
m.herp(); // Sometimes throws error
</code></pre>

<p>Methods:</p>

<pre><code>this.movements = new Array();
this.herp = function() {
    for (var i in this.movements) {
        if (!(this.movements[i] instanceof Movement)) {
            throw new Error("Oops"); // this.movements[i] is undefined
        }
    }
}
this.derp = function() {
    var newArray = new Array();
    for (var i in this.movements) {
        if (!this.movements[i].isFinished()) {
            newArray.push(this.movements[i]);
        }
    }
    this.movements = newArray;
}
</code></pre>
