← Back to Examples

JavaScript Operators

1. Arithmetic Operators

OperatorNameExample
+Addition5 + 3 = 8
-Subtraction5 - 3 = 2
*Multiplication5 * 3 = 15
/Division15 / 3 = 5
%Modulo (Remainder)5 % 3 = 2
**Exponent2 ** 3 = 8
Click to see results...

2. Comparison Operators

OperatorNameExample
==Loose Equality'5' == 5 → true
===Strict Equality'5' === 5 → false
!=Loose Inequality'5' != 5 → false
!==Strict Inequality'5' !== 5 → true
>Greater than5 > 3 → true
<Less than5 < 3 → false
>=Greater or equal5 >= 5 → true
<=Less or equal5 <= 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

OperatorNameExample
&&ANDtrue && false → false
||ORtrue || false → true
!NOT!true → false
??Nullish Coalescingnull ?? 'default' → 'default'
Click to see results...

4. Assignment Operators

Click to see results...

5. Type Coercion Gotchas

Click to see results...

← Back to Examples