The undefined value is a primitive value that is returned when a variable has not yet been assigned a value.
In some implementations this value compares equal to the null value. They are not actually the same, but this can sometimes provide a work-around for those implementations that do not provide a way to explicitly test for an undefined value.
If a variable is declared and no value is assigned to it, then it will contain the undefined value. It will exist and can be referred to in expressions and will affect them to the extent they can be affected by the value 'undefined'.
If a variable has never been declared and it is referred to, a run-time error will result. It does not exist let alone contain the 'undefined' value. There is one instance where referring to a non-existent variable does not generate an error, and that is to use it as an LValue in an assignment. Only the = operator can be used. The prefix and postfix increment/decrement operators should yield an error and so should the compound assignment operators, since the value to the left does not exist until after the assignment has taken place.
undefined = (void 0);
This whole area is somewhat mysterious and the (void 0) simulation really creates a null value which some browsers cannot distinguish from the undefined value.
Some implementations do not provide adequate protection against you corrupting this value. Be careful not to assign your own values to this variable. It will lead to unpredictable results if you do.
This is not available for use server-side with Netscape Enterprise Server 3.
// Assuming a or b has not been declared, this generates an error a += 10; // This doesn't a = 10; // This does alert(b);
ECMA 262 edition 2 - section - 4.3.9
ECMA 262 edition 3 - section - 4.3.9