js 常見邏輯運算符 - daniel-qa/Vue GitHub Wiki

  • js 常見邏輯運算符

#

Operator Name Example Description
== Equal x == y Returns true if x and y are equal.
!= Not equal x != y Returns true if x and y are not equal.
> Greater than x > y Returns true if x is greater than y.
< Less than x < y Returns true if x is less than y.
>= Greater than or equal to x >= y Returns true if x is greater than or equal to y.
<= Less than or equal to x <= y Returns true if x is less than or equal to y.
&& Logical AND x && y Returns true if both x and y are true.
|| Logical OR x || y Returns true if at least one of x or y is true.
! Logical NOT !x Returns true if x is false, or false if x is true.
?? Nullish coalescing x ?? y Returns x if x is not null or undefined, otherwise returns y.