Bitwise calculator
AND masks — it keeps only the bits set in both, so ANDing with 0x0F keeps the low nibble and clears the rest. OR sets — it turns bits on without disturbing the others. XOR toggles, and applying it twice with the same value returns the original, which is why it turns up in simple ciphers and in swapping without a temporary variable.
Operations are 32-bit, which is what JavaScript bitwise operators use. Values above 2³²−1 will wrap.
Bitwise operations compare two numbers bit by bit. 12 AND 10 is 8, because only the 8-bit is set in both. OR gives 14, XOR gives 6. Operations here are 32-bit.
How to use bitwise operations
The binary row is the one to read while learning. Bitwise operations are obvious once you can see the columns lining up — 1100 AND 1010 gives 1000 because only the leftmost column has a 1 in both. Everything else, including the masking and flag-setting idioms that fill real code, follows from that column-by-column comparison. Note that NOT operates on all 32 bits, so NOT 0 is 4294967295 rather than 1.
Questions
Keeps only bits set in both values. It is how masks work.