difference between null and undefined in JavaScript?
<p>According to <a href="http://stackoverflow.com/questions/5076944/what-is-the-difference-between-null-and-undefined-in-javascript">What is the difference between null and undefined in JavaScript?</a>, <code>null</code> and <code>undefined</code> are two different objects (having different types) in Javascript. But when I try this code</p>

<pre><code>var a=null;
var b;
alert(a==null);\\expecting true
alert(a==undefined);\\expecting false
alert(b==null);\\expecting false
alert(b==undefined);\\expecting true
</code></pre>

<p>The output of the above code is: </p>

<pre><code>true
true
true 
true
</code></pre>

<p>Now as <code>==</code> only matches the value, I thought that both <code>undefined</code> and <code>null</code> must have the same value. So I tried:</p>

<p><code>alert(null)</code> -> gives <code>null</code></p>

<p><code>alert(undefined)</code> -> gives <code>undefined</code></p>

<p>I don't understand how is this possible.</p>

<p>Here is <a href="http://jsfiddle.net/A89Qj/1/" rel="nofollow">the demo</a>.</p>

<p>Edit</p>

<p>I understand that <code>===</code> will give the expected result because <code>undefined</code> and <code>null</code> have different types, but how does type conversion work in Javascript in the case of <code>==</code>? Can we do explicit type conversion like we do in Java? I would like to apply a manual type conversion on <code>undefined</code> and <code>null</code>.</p>
