There isn't really an XOR logical operator, but the Bitwise XOR operator should work fine.
This is proven by evaluating the truth table in the example.
This seems to work fine even on MSIE where the sign bit exhibits some instability under Bitwise operations.
This is the truth table for two Boolean primitive values being operated on with the XOR operator.
<HTML> <HEAD></HEAD> <BODY> <TABLE BORDER=1 CELLPADDING=2> <TR> <TH>A</TH> <TH>B</TH> <TH>XOR</TH> </TR> <SCRIPT> for(a=0; a<2; a++) { for(b=0; b<2; b++) { document.write("<TR ALIGN=CENTER><TD>"); document.write(Boolean(a)); document.write("</TD><TD>"); document.write(Boolean(b)); document.write("</TD><TD>"); document.write(Boolean(a ^ b)); document.write("</TD></TR>"); } } </SCRIPT> </TABLE> </BODY> </HTML>
See also: | Bitwise XOR (^) |
Prev | Home | Next |
Logical OR (||) | Up | long |
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. |