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