Null:
Null is a javascript keyword, indicating "null". It is a javascript built-in object that does not contain any value.
Alert (typeof (null); // The result is an object.
When declaring a variable, it can be used as a placeholder to prevent an error (var a = NULL, indicating that the value of the variable A is "null ").
VaR A = NULL; alert (a); // The result is null.
Undefined:
Undefined is not a javascript keyword. It indicates that a variable has been declared but not initialized.
VaR A; alert (a); // The result is undefined.
Here I personally think that undefined itself is a value and its type is "undefined". In this case, there may be some logging ports, but let's look at the following example:
VaR A; alert (typeof (undefined); // The undefined result does not regard undefined as an undeclared variable. Otherwise, a runtime error occurs.
Alert (typeof (a); // result undefined alert (A = undefined); // result true alert (A === undefined) // result ture, the consistency operator returns true only when both types and values are equal.
We do not recommend that you use the IF (variable = undefined) method for value-free verification, because the default values of null and undefined in JavaScript are equal.
alert(null == undefined); //true
It is best to use the consistency operator or typeof to determine
If (variable = undefined) // or if (typeof (variable) = "undefined ")