var iResult = 25 ^ 3; alert(iResult); //outputs "26" 25 = 0000 0000 0000 0000 0000 0000 0001 1001 2 = 0000 0000 0000 0000 0000 0000 0000 0011 --------------------------------------------- XOR = 0000 0000 0000 0000 0000 0000 0001 1010
<html> <script language="JavaScript"> <!-- // integer = 32-bit binary representation // 6 = 00000000000000000000000000000110 // 3 = 00000000000000000000000000000011 // 5 = 00000000000000000000000000000101 document.write("6 ^ 3 = ", (6 ^ 3) ); --> </script> </html>