Checking for null/undefined in JavaScript
<p>Can this code</p>

<pre><code>if (typeof foo != "undefined" &amp;&amp; foo !== null) { }  
</code></pre>

<p>be safely refactored into this code?  </p>

<pre><code>if (foo != null) { }
</code></pre>

<p>Is it the exact same thing? (And if not, how is it different?)  </p>
