← Back to Examples
JavaScript Operators
1. Arithmetic Operators
| Operator | Name | Example |
| + | Addition | 5 + 3 = 8 |
| - | Subtraction | 5 - 3 = 2 |
| * | Multiplication | 5 * 3 = 15 |
| / | Division | 15 / 3 = 5 |
| % | Modulo (Remainder) | 5 % 3 = 2 |
| ** | Exponent | 2 ** 3 = 8 |
Click to see results...
2. Comparison Operators
| Operator | Name | Example |
| == | Loose Equality | '5' == 5 → true |
| === | Strict Equality | '5' === 5 → false |
| != | Loose Inequality | '5' != 5 → false |
| !== | Strict Inequality | '5' !== 5 → true |
| > | Greater than | 5 > 3 → true |
| < | Less than | 5 < 3 → false |
| >= | Greater or equal | 5 >= 5 → true |
| <= | Less or equal | 5 <= 4 → false |
Click to see results...
Always use === (strict equality)! The loose equality (==) does type coercion which can lead to unexpected results.
3. Logical Operators
| Operator | Name | Example |
| && | AND | true && false → false |
| || | OR | true || false → true |
| ! | NOT | !true → false |
| ?? | Nullish Coalescing | null ?? 'default' → 'default' |
Click to see results...
4. Assignment Operators
Click to see results...
5. Type Coercion Gotchas
Click to see results...
← Back to Examples