逻辑运算符

逻辑运算符采用布尔值true或false作为操作数,其返回值也是逻辑值,具体如下:

&&:逻辑与,当左右两边操作数都为 true 时,返回值为 true,否则返回 false。

||:逻辑或,当左右两边操作数都为 false 时,返回值为 false,否则返回 true。

!:逻辑非,当操作数为 true时,返回值为 false,否则返回 true。

原文地址:https://www.cnblogs.com/kojya/p/2842339.html