How does jQuery have the $ object constructor and the methods associated with the $?
<p>How is it that jQuery can do <code>$("#foo").addClass("bar")</code> and <code>$.ajax()</code>?</p>

<p>I'm creating a micro javascript framework and want to create a new instance of an object, such as <code>$("#hello")</code>. With this object there are associated methods, such as <code>addClass</code>, <code>css</code>, etc, just like with jQuery. So I could do something like</p>

<pre><code>$("#foo").addClass("remove").css("color", "red");
</code></pre>

<p>I have been successful in creating this. However, when I want to call a method from this object, such as <code>$.ajax</code>, the constructor function is overwritten, and I can call $.ajax, but not $("#foo").</p>

<p>Basically, how can jQuery do both?</p>
