Find out the difference between null and undefined?

Difference Between null and undefined

To treat undefined the same as null, you can use the equality operator (==). To differentiate between null and undefined, you need to use the identity operator (===).

 







  

    var firstVal = null;

    var secondVal;

    var equality = firstVal == secondVal;

    var identity = firstVal === secondVal;

    document.writeln("Equality: " + equality);

    document.writeln("Identity: " + identity);