title: Override jQuery functions simply by extending?
body: <p>This is related to, but not a duplicate of, another SO Q&amp;A <a href="https://stackoverflow.com/questions/4536788/override-jquery-functions">Override jQuery functions</a>.</p>
  <p>It is clear from the answer to the above question that the pattern to override a jQuery function is:</p>
  <pre><code>(function($){
  
      // store original reference to the method
      var _old = $.fn.method;
  
      $.fn.method = function(arg1,arg2){
  
          if ( ... condition ... ) {
             return  ....
          } else {           // do the default
             return _old.apply(this,arguments);
          }
      };
  })(jQuery);
  </code></pre>
  <br/>
  <h1><em><strong>But why!?</strong></em></h1>
  <p>I've been able to override a jQuery function simply by defining a function of the same name as the function to be overridden, within <code>$.extend</code> or <code>$.fn.extend</code>.</p>
  <p>Consider this:</p>
  <pre><code>// random example showing jquery function overriding
  $.fn.extend({
      hide: function() {
          $(this).css({&quot;color&quot;:&quot;red&quot;});
      }
  });
  
  $(&quot;#test&quot;).hide(); // this will actually paint the #test element red!
  </code></pre>
  <p><a href="http://jsfiddle.net/5V9rv/" rel="nofollow noreferrer">jsFiddle</a></p>
  <p><strong>I'd like to understand why <code>_old.apply(this,arguments)</code> would be the preferred way to override a jQuery function, as listed <a href="http://www.paulirish.com/2010/duck-punching-with-jquery/" rel="nofollow noreferrer">here</a> and <a href="http://www.bennadel.com/blog/1624-ask-ben-overriding-core-jquery-methods.htm" rel="nofollow noreferrer">here</a>.</strong></p>