Taiyi dev

Notes

Bit Manipulation

n & -n;
/*
  6 ^ -6 = 110 ^ 010 = 010
*/
n & (n - 1);
const isPowerOfTwo = x !== 0 && n & (n - 1 === 0);

XOR

a = 4;
b = 6;
a = a ^ b;
b = a ^ b;
a = a ^ b;
console.log(a, b); // 6 4

Reference