How to initalize a JavaScript function
<p>My understanding is that a function in JavaScript can have states. Some states need to be initialized just once. How do you do that so that calling the function does not re-initialize them?</p>

<p>For example, <code>$()</code> in jQuery is a function, not an object, and yet it seems to have states and act like an object.</p>

<p>I thought about creating an object for this, but what I want is really a facade function, much like the way <code>$()</code> works.</p>

<p>Thanks.</p>
