JavaScript 按位异或 (^) 运算符是什么?
如果两个位数不同,当使用按位或 (|) 运算符时,返回 1。
范例
你可以尝试运行下列代码来学习如何使用 JavaScript 按位异或运算符。
<!DOCTYPE html> <html> <body> <script> document.write("Bitwise XOR Operator<br>"); // 7 = 00000000000000000000000000000111 // 1 = 00000000000000000000000000000001 document.write(7 ^ 1); </script> </body> </html>
广告