title: Why does this change to the Array prototype not work in my jQuery plugin?
body: <p>I have added the following method to the Array prototype:</p>
  
  <pre><code>Array.prototype.foreach = function(func){
      for(var i = 0; i &lt; this.length; i++){
          if(!func(this[i]) === false) break; //return false from func in order to break the loop
      }
      return this;
  }
  </code></pre>
  
  <p>In the same file, <em>after</em> the above code, I have the following jQuery plugin:</p>
  
  <pre><code>jQuery.fn.addClassForEvents = function(){
  
      var that = this;
  
      arguments.foreach(function(event){
          that.bind(event[0], function(){
              that.addClass(event[0]);
          })
          .bind(event[1], function(){
              that.removeClass(event[0]);
          });
      });
  
      return this;
  }
  </code></pre>
  
  <p>In order to use this jQuery plugin, my code would look something like:</p>
  
  <pre><code>$('div').addClassForEvents(['mouseenter', 'mouseleave']);
  </code></pre>
  
  <p>However, the browser throws an error on the "arguments.foreach(...." line of the jQuery plugin, stating simply that </p>
  
  <blockquote>
    <p>Object # has no method 'foreach'</p>
  </blockquote>
  
  <p>Yet the <code>foreach</code> method works in other places of my code. Why is it undefined within this jQuery plugin?</p>