In JavaScript undefined
can be reassigned, so it is often advised to create a self executing function that assures undefined is actually undefined. As an alternati
Because of this:
var myVar1;
var myVar2 = null;
if (myVar1 === null) alert('myVar1 is null');
if (myVar1 === undefined) alert('myVar1 is undefined');
if (myVar2 === null) alert('myVar2 is null');
if (myVar2 === undefined) alert('myVar2 is undefined');
Anything set to null is not undefined - it's defined as null.