Atomics.xor() function in JavaScript

The Atomic object of JavaScript is an object and which provides atomic operations such as add, sub, and, or, xor, load, store etc. as static methods, these methods are used with SharedArrayBuffer objects.

The xor() function of the atomic object accepts a number and the position and, performs an xor operation on the given value at the given position.


Its syntax is as follows



 Live Demo

   <title>JavaScript Example</title>
   <script type="text/javascript">
      var arrayBuffer = new SharedArrayBuffer(16);
      var data = new Uint8Array(arrayBuffer);
      data[0] = 30;
      document.write(Atomics.xor(data, 0, 3));
      document.write(", "+Atomics.load(data, 0));


30, 29
Samual Sam
Samual Sam

Learning faster. Every day.