In fact, I have already listed all the "null" and "false" values in Javascript in the title, except that the values of Boolean are true and false, the "null" values of other data types mainly include undefined and defined. The types of these null values are:
( Typeof Undefined) = 'Undefined'
( Typeof Null ) = 'Object'
( Typeof "" ) = 'String'
( Typeof 0 ) = 'Number'
( Typeof False ) = 'Boolean' ( Typeof NAN) = 'number'
The common feature of these six values is that when you make judgments in the IF statement, the false branch is executed. In a broad sense, it means that these values are invalid values or null values corresponding to their data types. There are also five values! Returns true.
These values are also different. Among them, undefined and null are special. Although the null type is object, null does not have any object features, that is, we cannot execute null. tostring (), null. default call of object instances such as constructor. So in this sense, null and undefined have the greatest similarity. Look at the result of null = undefined (true) to better illustrate this. However, there is a difference between similarity and similarity, that is, the 10 + null result is 10, and the 10 + undefined result is Nan.
In addition, "", 0, and false although the if statement is expressed as "false value", they are all meaningful data, but are treated as "null" or "false value", because :"". tostring (), (0 ). tostring () and false. tostring () is a valid executable expression.
In fact, these six values do not bring too much problems to the process control in the above-mentioned differences. So what should they be differentiated? Note that the differences between these values and string values are quite large. The conversion relationships between these values and string values are as follows:
String (undefined) -> " Undefined "
String ( Null ) -> " Null "
String ( "" ) -> ""
String ( 0 ) -> " 0 "
String ( False ) -> " False " String (NAN)-> 'nan'
When declaring the language in the script tag, the previous version is included. The undefined values after 1.3 are null, and the previous undefined values are all undefined. Different versions have different results, and the latest versions are all classified as null.