Binary logical operators test a pair of Boolean values according to logical rules. If necessary, JavaScript will convert the operands that are passed to the expression into a Boolean value before testing them. You should consult the toBoolean rules for each type of object being passed to ensure that values are cast in a way that you expect.
The resulting value of a binary logical expression may be coerced to another data type on return.
There is no logical XOR operator. It can be simulated though by testing two Boolean values for inequality, since that is going to occur when either is one and the other is zero; the inequality will not test true if both are one or both are zero.
This is not to be confused with the bitwise operators, which yield a 32-bit integer value instead of the Boolean value yielded by a logical expression.
See also: | Logical AND (&&), Logical operator, Logical OR (||) |
Prev | Home | Next |
Binary bitwise operator | Up | Binary operator |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |