Javascript Reference
Categories: Operators

javascript Operators ^

@March 15, 2008, 1:22 a.m.
^ Firefox/Netscape/NN 2 IE 3 ECMA 1  

  

The bitwise exclusive OR (XOR) operator performs binary math on two operands (their binary values). Each column of bits is subjected to the Boolean XOR operation. If the value of a column in either operand (but not both operands) is 1, the result for that column position is 1. All other combinations yield a 0. The resulting value of the operator is the decimal equivalent of the binary result. For example, the binary values of 3 and 6 are 0011 and 0110, respectively. After an XOR operation on these two values, the binary result is 0101; the decimal equivalent is 5.

 
Example
 
var n = 3 ^ 6;

Powered by Linode.