We are frequently using the following code pattern in our JavaScript code
if (typeof(some_variable) != \'undefined\' && some_variable != null)
{
Both values can be easily distinguished by using the strict comparison operator:
Working example at:
http://www.thesstech.com/tryme?filename=nullandundefined
Sample Code:
function compare(){
var a = null; //variable assigned null value
var b; // undefined
if (a === b){
document.write("a and b have same datatype.");
}
else{
document.write("a and b have different datatype.");
}
}