&& must evaluate all expressions. 2 && 3 will first evaluate the βtruthβ 2 , which is the true value, but then it must also evaluate 3 . Then the last evaluated value is returned. If at least one value is not true, then the first such value is returned instead.
|| , on the other hand, returns the first plausible expression or the last incorrect if there are no right expressions.
The reason && returns the last possible value is because it just needs to check all expressions to return the result. || shouldn't do that. If the first expression for || verily, it ignores all the others. Similarly, if the first expression for && false, it ignores all the others (see Short Circuit in Logical Operations).
Xufox
source share