As recently as in the written test, found a lot of other types of conversion to a Boolean type of topics, so summarize!
First, the string type is converted to Boolean1. The case that the conversion J result is true
① any non-empty string
PS: Blank string also returns True
2. Case where the conversion result is false
① empty string
Second, the number type is converted to Boolean1. case where the conversion result is true
① any non-0 numeric value (including infinity)
2. Case where the conversion result is false
①0
②nan
Iii. the type of object is converted to Boolean1. case where the conversion result is true
① any object (including empty objects)
② array objects (including empty arrays)
③ Regular Expressions
2. Case where the conversion result is false
① Empty objects
PS: Here to distinguish with the previous empty object {}, an empty object indicates that the object was created, but there is nothing in it, and the empty object represents the creation, which is a null
Iv. undefined type converted to Boolean1. can only return false
JS other type value converted to a Boolean type rule