Hướng dẫn or in javascript
The logical OR ( If If a value can be converted to Examples of expressions that can be converted to false are: Even though the The logical OR
expression is evaluated left to right, it is tested for possible "short-circuit" evaluation using the following rule: Short circuit means that the
Operator precedence The following expressions might seem equivalent, but they are not, because the
ExamplesUsing ORThe following code shows examples of the
Note: If you use this operator to provide a default value to some variable, be aware that any falsy value will not be used. If you only need to filter out
Conversion rules for booleansConverting AND to ORThe following operation involving booleans:
is always equal to:
Converting OR to ANDThe following operation involving booleans:
is always equal to:
Removing nested parenthesesAs logical expressions are evaluated left to right, it is always possible to remove parentheses from a complex expression following some rules. The following composite operation involving booleans:
is always equal to:
Specifications
Browser compatibilityBCD tables only load in the browser See also |