comparing against undefined
<p>Is it unsafe to compare a variable against undefined?</p>

<pre><code>if(foo == undefined)
</code></pre>

<p>vs</p>

<pre><code>if(foo == 'undefined')
</code></pre>

<p>Is the first example sufficient? Or should it be something like</p>

<pre><code>if('undefined' in window){
     //compare against undefined
} else {
    //compare against 'undefined'
}
</code></pre>

<p>since <code>undefined</code> exists on the <code>window</code> object? Will it exist in all browsers? Or should I simply compare to <code>== 'undefined'</code>? I've found some similar questions on SO, but no answers regarding the existance of the undefined property on the window object.</p>
