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 if statements) to automatically execute corresponding Boolean conversions. Please refer to the following code:
Var msg = "Hello World ";
If (msg ){
Alert ("Valus is true ");
}