Does jQuery "short circuit" calls on empty collections?
<p>Suppose I have the following jQuery:</p>

<pre><code>$container = $('#container');

$container.find('.foo').hide(500).remove();
</code></pre>

<p>There's no point in calling anything past <code>$container</code> if there is no <code>#container</code> element on the page, so I <strong>could</strong> do this:</p>

<pre><code>if ($container.length &gt; 0) { // Is there such an element?
  $container.find('.foo').hide(500).remove();
}
</code></pre>

<p>But is there any point to checking? <strong>If <code>$container</code> is an empty collection, will jQuery automatically ignore the rest of the calls?</strong></p>

<p>I've verified that the code in an <code>each</code> callback is never called on empty collections, but I'm not sure how to test this for other chained methods; I don't know whether <code>hide()</code> is being called or not, for instance.</p>
