Today we're talking about a Boolean type in a data type that returns True and false two literals, and it needs to be noted that the literal value is case-sensitive, meaning that all but the lowercase are just identifiers.
The following are mainly about the various data types and corresponding transformation rules:
Value with value converted to true for data type conversion to False
--------------------------------------------------------------------------------
Boolean true False
String any non-empty string "" (empty string)
Number any non 0 digit value 0 and Nan
Object any objects Null
Undefined not suitable for Undefined
--------------------------------------------------------------------------------
These conversion rules are important to understand that a Process control statement, such as an if statement, automatically performs a corresponding Boolean transformation, see the following code:
Copy Code code as follows:
var msg= "Hello World";
if (msg) {
Alert ("Valus is true");
}