VOOZH about

URL: https://www.geeksforgeeks.org/javascript/bitwise-xor-assignment-operator-in-javascript/

⇱ Bitwise XOR Assignment (^=) Operator in JavaScript - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Bitwise XOR Assignment (^=) Operator in JavaScript

Last Updated : 23 Jul, 2025

The Javascript Bitwise XOR assignment is represented by (^=). It is used to perform a bitwise XOR operation on both operands and assign the result to the left operand.

Syntax:

a ^= b 
// a = a ^ b

Where -

  • a = First operand
  • b = Second operand
 

Example: In this example, we will perform the basic Bitwise XOR assignment operation on both operands.

Output: The number 2 is represented as 10 in binary, and the number 3 is represented as 100 in binary. When the XOR assignment is performed 110  is returned which after conversion to decimal returns 6.

6 // Bit presentation 110

Example 2: In this example, we will use a bitwise XOR assignment operation on both operands and display the result.

Output:  The number 14 is represented as 1110 in binary, and the number 18 is represented as 10010 in binary. when the XOR assignment is performed 11100 is returned which conversion to decimal is 28.

28 // Bit presentation 11100

We have a complete list of Javascript Assignment Operators, to go through those please check the Javascript Assignment Operator article.

Supported Browsers:

  • Chrome 1
  • Edge 12
  • Firefox 1
  • Opera 3
  • Safari 1
Comment