While reading the JavaScript documentation I came across a section that confused me:
"Logical operators are typically used with Boolean (logical) values; when they are, they return a Boolean value. However, the && and || operators actually return the value of one of the specified operands, so if these operators are used with non-Boolean values, they may return a non-Boolean value. The logical operators are described in the following table.
&& Operator: expr1 && expr2
(Logical AND) Returns expr1 if it can be converted to false; otherwise, returns expr2. Thus, when used with Boolean values, && returns true if both operands are true; otherwise, returns false.
|| Operator: expr1 || expr2
(Logical OR) Returns expr1 if it can be converted to true; otherwise, returns expr2. Thus, when used with Boolean values, || returns true if either operand is true; if both are false, returns false."
Let's say you have:
var a3 = false && true;
so taking into the consideration the rule for the "and" operator, the variable a3 should contain the value true since "false" cannot be converted to false.
false
be converted tofalse
?false
isfalse
. - Blender