(1) and operators (&&)
The execution process with the operator is as follows: javascript obtains each operand in sequence and converts them to a Boolean variable. If it is false, the value of this operand is directly returned (note, returns the original value before conversion, not necessarily a Boolean value), which interrupts the processing of the next operand. Otherwise, the next operand is processed. If the last operand still corresponds to the Boolean variable true, the value of the last operand is returned. The following Code demonstrates the execution principle:
VaR A = "1" & True & 0 & false & "ABC ";
Alert (a); // The value of A is 0.
VaR B = "ABC" & True & "123 ";
Alert (B); // The value of visible B is "123 ";
(2) or operator (|)
Similar to the operator, or the execution process of the operator is as follows: javascript obtains each operand in sequence and converts them to a Boolean variable. If it is true, the value of this operand is directly returned, interrupt the processing of the next operand; otherwise, continue to the next operand. If the last operand still corresponds to the Boolean variable false, the return value is returned. The following code demonstrates the execution principle:
VaR A = "ABC" ||" 123 ";
Alert (a); // The value of A is "ABC"
VaR B = false | "" | 0;
Alert (B); // The value of A is 0.
Or operator is often used in development.
(3) Non-operator (!)
Unlike the first two operators, non-operators always return Boolean variables. For example:
VaR A =! "ABC ";
Alert (a); // display the value of a as false