JavaScript extension on Array
<p>I'm writing an extension method for Array which accepts a function and then call it for each items in the Array.</p>

<p>It works fine except the extension itself is added into the Array after the function call. So at the alert part, the third alert shows my foo function in string.</p>

<p>Here's the code:</p>

<pre><code>Array.prototype.foo = function (F) {
    for (var i in this) {
        this[i] = F(this[i]);
    }
}

var items = ["a", "b"];

items.foo(function (data) {
    return data + 1;
});

for (var i in items) {
    alert(items[i]); // expected to see a1 and b1 but also displayed foo as string.
}
</code></pre>
