JavaScript Operators
This page covers JavaScript operators including math operators, bitwise operators, and logical operators.
Math
| Operator | Meaning |
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| / | Division |
| % | Modulus |
| ++ | Increment |
| –– | Decrement |
| - | Negation |
Strings are concatenated together using the "+" operator.
Bitwise Operators
These operators work at the bit level performing the operator function on a bit per bit basis. The operation must be thought of as binary, octal, or hexadecimal values (depending on preference) to consider how it works. Consider the decimal number 15.
15 & 3 = 3 - Equivalent binary: 1111 & 0011 = 0011
15 | 3 = 15 - Equivalent binary: 1111 | 0011 = 1111
15 | 16 = 31 - Equivalent binary: 1111 | 10000 = 11111
15 | 30 = 31 - Equivalent binary: 1111 | 11110 = 11111
| Operator | Meaning |
| & | AND |
| ~ | NOT |
| | | OR |
| ^ | exclusive OR |
| << | Left shift |
| >> | Right shift |
| >>> | Right shift, fill with zeros |
|