Today we are talking about a boolean type in the data type. It returns both the true and false face values. Note that the face values are case sensitive, that is, all except lower-case letters are identifiers.
The following describes various data types and corresponding conversion rules:
Convert data type to true to false
--------------------------------------------------------------------------------
Boolean True False
String any non-empty string "" (empty string)
Number any non-zero numeric values 0 and Nan
Any object of the object is null.
Undefined is not applicable to undefined.
--------------------------------------------------------------------------------
These conversion rules are very important for understanding the process control statements (such as the if statement) to automatically execute the corresponding Boolean conversion. Please refer to the followingCode:
Copy codeThe Code is as follows: var MSG = "Hello World ";
If (MSG ){
Alert ("valus is true ");
}