TypeScript supports the following bitwise operators. To understand the examples, you must assume that variable A holds 2 as value and variable B holds 3 as value:
Operator |
Description |
Example |
& |
Known as the bitwise AND operator, it performs a boolean AND operation on each bit of its integer arguments. |
(A & B) is 2 |
| |
Known as the bitwise OR operator, it performs a boolean OR operation on each bit of its integer arguments. |
(A | B) is 3. |
^ |
Known as the bitwise XOR operator, it performs a boolean exclusive OR operation on each bit of its integer arguments. Exclusive OR means that either operand one is true or operand two is true, but not both. |
(A ^ B) is 1. |
~ |
Known as the bitwise NOT operator, ... |