The best way to check for a null values is
if ( testVar !== null )
{
// do action here
}
and for undefined
if ( testVar !== undefined )
{
// do action here
}
You can assign a avariable with undefined.
testVar = undefined;
//typeof(testVar) will be equal to undefined.