1, Overview:
※undefined and Null are two data types in JavaScript (other types are: Boolean, String, Number, Object).
The ※undefined type has only one value: The Undefined;null type has only one value: null.
2,undefined Type Related instructions:
※ The value of this variable is undefined when the Var is used to declare the relevant variable but is not initialized.
※ This is different from the non-declared (that is, undefined) variables, if the use of undeclared variables, will be an error referenceerror:s is not defined.
※ Only one action is allowed for variables that have not been declared: The typeof operator is used to detect its data type, but it is confusing that the typeof operator, which executes uninitialized and undeclared variables, returns the undefined value. This result has its logical rationality, although the two variables from a technical point of view have an essential difference, but in fact, no matter what kind of variable is not possible to perform real operation.
3,null Type Related instructions:
※ First, NULL is an initialized value. From a logical point of view, a null value represents an empty object pointer, so using the TypeOf operator to detect a null value (or a variable that detects a null value) returns a value of "object";
※ As long as the variable intended to save the object does not actually hold the object, it should be explicitly initialized to a null value, which will not only reflect the convention of NULL as a null object pointer, but also help to further differentiate between null and undefined.
4. Other places to be aware of:
※ It says that if an undeclared variable is used, but if it is accessed as a property of an object, even if the property is not declared (defined), it will not error, but return undefined. See the following example:
Alert (SSS);//Error
var o = {}; alert (o.sss);//undefined.
In general, if the property of the Access object returns a undefined value, it means that this property is undefined (and of course, var o = {sss:undefined} also returns undefined).
Description of the Undefined/null type in JavaScript