How can jQuery behave like an object and a function?
<p><code>jQuery</code> or <code>$</code> seems to be a function:</p>

<pre><code>typeof $; // "function"
</code></pre>

<p>And it acts like one:</p>

<pre><code>$('div').removeClass(); // $ constructs a new object with some methods like removeClass
</code></pre>

<p>But when I drop the function parentheses it behaves like an object:</p>

<pre><code>$.each(/* parameters */); // $ is an object with some methods like each
</code></pre>

<p>I'd like to know how this is possible and how I can implement this behaviour to my own functions.</p>
