我一直在使用MDN Docs - Logical Operators作为理解逻辑 AND 运算符的参考框架。
我已经理解了这些代码示例中的大部分,尤其是前 4 个,如下所示:
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
但是我有问题理解a5
,a6
并且a7
。
我无法理解这两个字符串a5="Cat" && "Dog"
是如何评估的true && true returns Dog
我也无法理解为什么字符串“Cat”作为a6=false && "Cat" // f && t returns false