Arithmetic
+ - * / % (remainder) ** (power) ++ --
Assignment
= += -= *= /= — x += 5 means x = x + 5.
Comparison
| Operator | Meaning |
|---|---|
=== |
equal value and type |
!== |
not equal value or type |
== |
equal value (converts types — avoid) |
> < >= <= |
greater / less |
5 == '5' is true, but 5 === '5' is false. Always prefer ===.
Logical
&& (and), || (or), ! (not)
Ternary
condition ? valueIfTrue : valueIfFalse
String joining
+ also joins strings: 'Hi ' + 'Asha'.
Example
Example — Operators in action
HTML
<pre id="out"></pre>
<script>
const a = 10, b = 3;
const lines = [
'a + b = ' + (a + b),
'a % b = ' + (a % b),
'a ** 2 = ' + (a ** 2),
'5 == "5" → ' + (5 == '5'),
'5 === "5" → ' + (5 === '5'),
'a > 5 && b > 5 → ' + (a > 5 && b > 5),
'Result: ' + (a >= 10 ? 'Pass' : 'Fail')
];
document.getElementById('out').textContent = lines.join('\n');
</script>