Logical Operators
Posted rosendolu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Logical Operators相关的知识,希望对你有一定的参考价值。
Logical Operators
Operator | Description | Useage |
---|---|---|
Logical AND (&& ) |
expr1 && expr2 | Returns expr1 if it can be converted to false; otherwise, returns expr2. Thus, when used with Boolean values, && returns true if both operands are true; otherwise, returns false. |
Logical OR (|| ) |
expr1 || expr2 |
Returns expr1 if it can be converted to true; otherwise, returns expr2. Thus, when used with Boolean values, || returns true if either operand is true. |
Logical NOT (! ) |
!expr | Returns false if its single operand can be converted to true; otherwise, returns true. |
Falsy
- null;
- NaN;
- 0;
- empty string ("" or ‘‘ or ``);
- undefined.
以上是关于Logical Operators的主要内容,如果未能解决你的问题,请参考以下文章