JavaScript Swapping Two Integers with Bitwise XOR (without additional memory allocation)


Example

var a = 11, b = 22;
a = a ^ b;
b = a ^ b;
a = a ^ b;
console.log("a = " + a + "; b = " + b);// a is now 22 and b is now 11