var undefined = true;
<p>I'm doing some experimenting with this malicious JavaScript line: <code>var undefined = true;</code></p>

<p>Every uninitialized variable in JavaScript has the value of <code>undefined</code> which is just a variable that holds the special value of <code>'undefined'</code>, so the following should execute the <code>alert</code>:</p>

<pre><code>var undefined = true, 
    x;

if (x) {
    alert('ok');
}
</code></pre>

<p>But it doesn't, and my question is why?</p>

<p>On further experimentation, I tried the following:</p>

<pre><code>var undefined = true, 
    x = undefined;

if (x) {
    alert('ok');
}
</code></pre>

<p>This time, the <code>alert</code> is executed.</p>

<p>So my question is...since in the first snippet <code>x</code> holds <code>undefined</code> (because it is not initialized), why didn't the <code>alert</code> execute?  The strange thing is that when explicitly stating that <code>x</code> is <code>undefined</code> (<code>x = undefined</code>), the <code>alert</code> executed...</p>
