JavaScript evaluates to false values: null, False, 0, undefined, NaN, and "" (empty string). Remember that the value of this Nan class like Infinity (Infinity) is judged to be true and not false. However, NaN is judged false. In addition to these, all other values are judged to be true.
One Undefined type
There is only one value undefined
The following three cases typeof return type is undefined
1. When the variable is not initialized
2. When a variable is not defined
3. When the function has no explicit return value (undefined is returned when the function has no return value)
Undefined is not equivalent to undefined value
typeof does not really differentiate whether it is undefined
Look at the following sample code:
var otemp;
Alert (typeof otemp); Outputs "undefined"
Alert (typeof OTEMP2);//outputs "undefined"
Alert (OTEMP2 = = undefined); Error OTEMP2 undefined cannot use other operations except typeof that cannot be used to OTEMP2 other
When the variable
two Null type
Only one null,undefined is handled by a null derivation, so undefined = = NULL
Undefined is the variable declared but not initialized,
Null indicates an object that does not exist
three NaN value
is a special value that represents a non-number (not a digit)
Type conversion failure will return Nan
e.g. to convert a word blue to a numeric value will fail because there is no equivalent value
NaN does not equal itself
That is, Nan = = Nan is False
Judge Nan using IsNaN ();
JavaScript True/false