Javascript Function like Objects i.e. "$" can be used as a function e.g. $() as well as an object $
<p>Questions in the title. I've always wondered and failed to find out from the jQuery source. How this is done.</p>

<p>To reiterate. In jQuery: how does the "$" become a function e.g."$()" as well as an object "$."</p>

<p>I can create it one way OR the other like so...</p>

<pre><code>var $ = function(){
    return {each:function(){console.log("Word")}}
}
// $.each(); FAIL!
$().each(); // Word


var $ = {
    each:function(){console.log("Word")}
}
$.each(); // Word
//$().each(); FAIL!
</code></pre>
