Bitwise XOR Assignment (^=) Operator in JavaScript Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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 operandb = Second operand Example: In this example, we will perform the basic Bitwise XOR assignment operation on both operands. JavaScript let a = 2; // Binary representation 10 let b = 4; // Binary representation 100 console.log(a ^= b); 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. JavaScript let a = 14; // Binary representation 1110 let b = 18; // Binary representation 10010 console.log(a ^= b); 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 1Edge 12Firefox 1Opera 3Safari 1 Comment More info V vishalkumar2204 Follow Improve Article Tags : JavaScript Web Technologies javascript-operators Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)9 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like