How to check for non-existent class? (getElementsByClassName)
<pre><code>arr = document.getElementsByClassName(type2);  // suppose type2 is not available in the dom - class = "some_class"
// check for empty
</code></pre>

<p>This snippet returns </p>

<p>[object HTMLCollection]</p>

<p>which has a length of 0.</p>

<p>Is this the best way to check for the class not existing when getElementsByClassName is used, i.e., just check for a length of 0?</p>
