Why does my code replace the jQuery.error function?
<p>I have the following code, which seems to override the jQuery.error function:</p>

<pre><code>    $.test = function(){
        var test = this;

        test.error = function(){
            console.log('Why is this function getting called');
        };    
    };

    $(document).ready(function(){
        var someObj = $.test();
        $.error();
    });
</code></pre>

<p>This code will output 'Why is this function getting called' in the console. </p>

<p>However, if I change my code slightly, the native jQuery error function is called:</p>

<pre><code>$(document).ready(function(){
    var someObj =  new $.test();
    $.error();
});
</code></pre>

<p>It seems that in the first example, 'this' refers to jQuery, but in the second example it refers to someObj. Why is this?</p>
