Using evaluated variable values instead of the actual type
<pre><code>var foo;

console.log(typeof foo); //"undefined"

if(typeof foo === 'undefined')
    console.log(1);

if(!foo)
    console.log(2);
</code></pre>

<p>In my example above, the console will log both "1" and "2", since <code>undefined</code> evaluates as <code>false</code>. The same thing will happen for <code>null</code>, <code>NaN</code>, <code>""</code> (empty string) etc.</p>

<p>Is it more common to use the <code>typeof</code> operator and compare the string value, rather than using the evaluated boolean value? Is there any difference besides readability? Any pros and cons?</p>
