What is Bitwise XOR Operator (^) in JavaScript?


It performs a Boolean exclusive OR operation on each bit of its integer arguments. Exclusive OR means that either operand one is true or operand two is true, but not both.

Example

You can try to run the following code to learn how to work with Bitwise XOR Operator

Live Demo

<html>
   <body>
      <script>
         <!--
         var a = 2;   // Bit presentation 10
         var b = 3;  // Bit presentation 11
         document.write("(a ^ b) => ");
         result = (a ^ b);
         document.write(result);
      </script>
   </body>
</html>

Updated on: 08-Jan-2020

869 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements