Convert various data types to Boolean values

The Boolean type has only two values: true (true) \ false (false).
Calling the conversion function: Boolean() can convert all types of values ​​in ECMAScript into corresponding Boolean values.

1. All numbers except 0 and NaN are true when converted to Boolean type.

NaN: (not a numeric value)

2. All characters except "" are converted to Boolean and are true

3. Convert null and undefined to Boolean type to false

Guess you like

Origin blog.csdn.net/drunk2/article/details/125928121