jQuery.extend and jQuery.fn.extend
<p>I am making some test with <code>extend</code> and I got a little puzzled after some observations I made. First observations:</p>

<pre><code>console.log($.extend === $.fn.extend); // trure
// and since $ === jQuery then ...
console.log(jQuery.extend === jQuery.fn.extend); // true
</code></pre>

<p>So far so good, isn't it? Given the above results I then thought that doing this:</p>

<pre><code>// SNIPPET 1
$.extend({
   log: function(m) {
      console.log(m);
   }
});
</code></pre>

<p>and this:</p>

<pre><code>// SNIPPET 2
$.fn.extend({
   log: function(m) {
      console.log(m);
   }
});
</code></pre>

<p>was the same very thing. But in fact things stand in a very different way. In fact if you run SNIPPET 1 and then do:</p>

<pre><code>$("body").log("whatever");
</code></pre>

<p>you get an error (log is not defined). But you can do:</p>

<pre><code>$.log("whatever");
</code></pre>

<p>If you run instead SNIPPET 2 you get the opposite result, that is to say:</p>

<pre><code>$("body").log("whatever"); // this will work
$.log("whatever"); // this won't
</code></pre>

<p>What the heck? I appreciate the fact that <code>.extend</code> extends the object against which it is executed (<code>$</code> vs <code>$.prototype</code>) but what I do not get is how iit does it! Expecially given the fact that:</p>

<pre><code>$.extend === $.fn.extend // true
</code></pre>

<p>The function is the same!! How can it produce 2 different results?</p>
