0

I have the following example

    a1 = true  && true       // t && t returns true
    a2 = true  && false      // t && f returns false
    a3 = false && true       // f && t returns false
    a4 = false && (3 == 4)   // f && f returns false
    a5 = 'Cat' && 'Dog'      // t && t returns "Dog"
    a6 = false && 'Cat'      // f && t returns false
    a7 = 'Cat' && false      // t && f returns false
    a8 = ''    && false      // f && f returns ""
    a9 = false && ''         // f && f returns false

I'm confused. Why do the following variables a5 and a8 return a string instead of a boolean?

NikLaz
  • 1
  • The `&&` operator is not simply a logical "and" operation. The returned value of `&&` depends on the types of the operands. – Pointy Mar 26 '21 at 13:55

0 Answers0