In TypeScript (and JavaScript), the following values will be evaluated as false in conditional statements:

In TypeScript (and JavaScript), the following values ​​will evaluate to false in conditional statements:

1. false: The Boolean value false itself will be judged as false.
2. 0: The number 0 is judged as false.
3. -0: Negative zero is also judged as false.
4. NaN: Non-numeric values ​​are judged as false.
5. '' (empty string): The empty string is judged as false.
6. null: A null value (null) is judged as false.
7. undefined: Undefined values ​​are judged as false.
These values ​​are called "Falsy values". In a conditional statement (such as an if statement), the condition is considered false when the expression evaluates to one of these false values, and true otherwise. It is worth noting that except for the above false values, all other values ​​will be judged as true.

Guess you like

Origin blog.csdn.net/qq_39962271/article/details/132245400