February 2018
Intermediate to advanced
298 pages
8h 22m
English
Again, Atomics.xor method performs a bitwise XOR operation, which is an exclusive OR (that is, it is an OR gate which gives 0 when both inputs are 1)
const sab = new SharedArrayBuffer(1);const arr = new Uint8Array(sab);arr[0] = 5; // 5 is 0101 in binary.Atomics.xor(arr, 0, 12); // 10 is 1100 in binaryconsole.log(Atomics.load(arr, 0));
Atomics.xor here performed a XOR operation between arr[0] and the number 10.
This outputs:
9
Read now
Unlock full access