Logical Operators

Logical operators work with the boolean values true and false.

  • Logical AND: a && b

      true && true  // is `true`
    
      true && false  // is `false`
    
      false && true  // is `false`
    
      false && false  // is `false`

    If the left-hand side is false, the right-hand side is not evaluated.

  • Logical OR: a || b

      true || true  // is `true`
    
      true || false  // is `true`
    
      false || true  // is `true`
    
      false || false // is `false`

    If the left-hand side is true, the right-hand side is not evaluated.

Last updated