On this page本页内容
$or¶Evaluates one or more expressions and returns 计算一个或多个表达式,如果其中任何表达式为true if any of the expressions are true. true,则返回true。Otherwise, 否则,$or returns false.$or返回false。
$or has the following syntax:语法如下所示:
For more information on expressions, see Expressions.有关表达式的详细信息,请参阅表达式。
$or uses short-circuit logic: the operation stops evaluation after encountering the first true expression.$or使用短路逻辑:操作在遇到第一个真表达式后停止计算。
In addition to the 除了false boolean value, $or evaluates as false the following: null, 0, and undefined values. false布尔值,$or的计算结果为false,还包括以下值:null、0和undefined的值。The $or evaluates all other values as true, including non-zero numeric values and arrays.$or将所有其他值计算为true,包括非零数值和数组。
| Result | ||
|---|---|---|
{ $or: [ true, false ] } |
true | |
{ $or: [ [ false ], false ] } |
true | |
{ $or: [ null, 0, undefined ] } |
false | |
{ $or: [ ] } |
false |