Logical Operators

The logical operators are the logical && (AND) operator, the logical || (OR) operator, and the logical ! (NOT) operator. They are often used in conditionals such as if statements to combine and negate conditions.

  • Logical AND (&&) Expression

    Evaluates from left to right. If the first expression evaluates to a falsy value, it is returned; otherwise, the evaluated value of the second expression is returned. This expression can be used to combine conditions in if statements and other conditional statements.

  • Logical NOT (!) Expression

    Negates an expression.

  • Logical OR (||) Expression

    Evaluates from left to right. If the first expression evaluates to a truthy value, it is returned; otherwise, the evaluated value of the second expression is returned. This expression can be used to test more than one condition in if statements and other conditional statements.

Share

HTML | BBCode | Direct Link