Home > Article > Web Front-end > Is the boolean value of empty string in js false?
#Is the boolean value of empty string in js false?
#The boolean value of empty string in js is false.
Boolean value is a logical value, only true and false (true and false).
Six situations in which Boolean values in js are false
The following 6 values are false when converted into Boolean values, and other conversions are true
1. undefined (undefined, appears when the value cannot be found)
2. null (represents a null value)
3. false (false of Boolean value, string "false" Boolean The value is true)
4, 0 (number 0, string "0" Boolean value is true)
5, NaN (occurs when the result cannot be calculated, indicating "non-numeric value"; but typeof NaN==="number")
6, "" (double quotation mark) or '' (single quotation mark) (empty string, it is also true when there are spaces in the middle)
Pay attention to the empty string Array empty objects, negative values converted to Boolean values are all true
Recommended tutorial: "JS Tutorial"
The above is the detailed content of Is the boolean value of empty string in js false?. For more information, please follow other related articles on the PHP Chinese website!