JavaScript OR
JavaScript OR Operator is used to perform logical OR operations on two Boolean operands. OR Operator is generally used in creating complex conditions like combining two or further simple conditions.
The symbol used for JavaScript OR Operator is ||. The syntax to use JavaScript OR Operator with operands “a” and “b” is “a||b”. JavaScript OR Operator supports chaining. For illustration, the syntax to pen a condition with four Boolean valuations is a|| b|| c|| d. These expressions return true if any of the operands is true. The following verity table provides the output of the JavaScript OR operator for different values of operands.
a | b | a || b |
True | True | True |
True | False | True |
False | True | True |
False | False | False |
JavaScript OR Operation returns true if any of the operands is true, otherwise, it returns false.
In the following illustration, we use logical OR Operator in the If Statement’s Condition to fuse two simple conditions to form a complex condition.