Why do I get "Can't execute code from a freed script"
<p>First of all: Yes, I've read <a href="http://stackoverflow.com/questions/5812180/cant-execute-code-from-a-freed-script-ie6-ie7-ie8-ie9">this answer</a>... And, Yes, there's no meta after script (as I do not have any meta on my page), and, No, there's no timeout or ajax-request</p>

<p>I have following helper-method (Yes, I could have made a prototype-method ...):</p>

<pre><code>function removeElementFromArray(array, compareMethod) {
    if (!array) {
        return;
    }
    if (!$.isFunction(compareMethod)) {
        return;
    }
    var index = getIndexOfElement(array, compareMethod);
    if (index &lt; 0) {
        return;
    }
    array.splice(index, 1);
}
function getIndexOfElement(array, compareMethod) {
    if (!array) {
        return -1;
    }
    if (!$.isFunction(compareMethod)) {
        return -1;
    }
    for (var i = 0; i &lt; array.length; i++) {
        var element = array[i];
        if (compareMethod(element)) {
            return i;
        }
    }
    return -1;
}
</code></pre>

<p>I am calling this with:</p>

<pre><code>$foo.on('click', function () {
    removeElementFromArray(window.myArray, function (element) {
        return // some condition
    });
});
</code></pre>

<p>I am getting the exception "SCRIPT5011: Can't execute code from a freed script" (only in IE render-mode &lt; 10) in following line:</p>

<pre><code>array.splice(index, 1);
</code></pre>

<p>But not on the first call, but on any subsequent ones (for the same array) ...</p>

<p>But I can't think of a single reason why this exception occurs, as I am accessing the array in other lines as well in the callstack (as you can see, eg getIndexOfElement, where I iterate over the array).</p>

<p>Can anybody help me out?</p>
