agyanadda@gmail.com

JS Operators

JavaScript Basics 1 min read Updated Dec 1, 2026 Topic 7 of 38

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>

Test Yourself With Exercises

Exercise 1 Multiple Choice

What is 10 % 3?

Exercise 2 True / False

5 === '5' is true.

Exercise 3 Fill in the Blank

The logical AND operator is written as ___.

Frequently Asked Questions

If one side of + is a string, JavaScript joins them as text. Convert first with Number('2') + 2 to get 4.