There is the difference between an unoccupied variable and undefined:
var x; //x is equal to *undefined* alert(y); //error, y is undeclared
This does not contradict each other, but it is redundant:
var x = undefined;
Think of undefined as just the value that the variable has if it was not initialized, or the value that the property of the object has when it was not initialized or declared.
source share