JS undefined


undefined usually refers to a variable which value has not been declared.

alert(typeof(y)); //undefined
var y;
alert(typeof(y)); //undefined
var y=5;
alert(typeof(y)); //number


If a variable is declared, but without a value, using in to check:

var y;
alert(typeof(y)); //undefined
if (y in window) alert("yes"); //yes


A variable can have a value "undifined".

var x="undefined";
var y;
if (typeof(y) == x) alert("yes"); //yes
alert(x); //undefined
alert(typeof(x)); //string