Calling a javascript function as an array method
<p><strong>Update</strong>: I know there are existing implementations of forEach method. The purpose of doing this is to learn and improve my Javascript skills.</p>

<p>I am trying to implement a forEach method for array objects. What I am doing is the following:</p>

<pre><code>var list = ['one', 'two', 'three'];

function forEach(callback){
    for(var n = 0; n &lt; this.length; n++){
        callback.call(this[n], n);
    }
};

list.forEach(function(index){
        console.log(index);
        console.log(this);
    }
);
</code></pre>

<p>I am not very good with javascript and I am trying to get better so I've been reading a little bit and I now know that if I do this kind of thing, the context of the "forEach" function would be the object which is calling it, in this case "list".</p>

<p>When this code runs I get the error: "Uncaught TypeError: Object one,two,three has no method 'forEach'".</p>

<p>What is it I am not understanding?</p>

<p>Thanks!</p>
