The undefined type is generally assigned to those variables that are declared but not yet initialized (i.e. var text;).
Keep in mind that if a variable is not declared, the script will stop causing an error.
Undeclared identifiers are not the same as undefined ones.
Following examples shows the difference between them:
var text; // undefined
// var zipcode; //left out due comments
alert (test); //undefined
alert (zipcode); // cause an error!
However the operator typeof may be applied to undeclared identifiers and it will, confusingly, return undefined as the type.
Example
The undefined data type example:
Comments
No comments have been made yet.
Please login to leave a comment. Login now