JavaScript Operators

Arithmetic, assignment, comparison and logical operators.

✍️ 3 exercises + code challenge in this lesson

Arithmetic

+ - * / % (remainder) ** (power) ++ --

Assignment

= += -= *= /=

Comparison

=== equal value and type, !== not equal, > < >= <=

Logical

&& (and), || (or), ! (not), ?? (nullish coalescing)

Always use === instead of ==. == converts types first, so "5" == 5 is true, which causes bugs.

Key Takeaways: JavaScript Operators

Mastering JavaScript Operators helps you write clean and reliable JavaScript code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

JavaScript Operators Code Example

JavaScript
<pre id="out"></pre>
<script>
const log = (...a) => document.getElementById("out").textContent += a.join(" ") + "\n";
let x = 10;
x += 5;
log("x =", x);
log("17 % 5 =", 17 % 5);
log("2 ** 8 =", 2 ** 8);

log('"5" == 5  →', "5" == 5);
log('"5" === 5 →', "5" === 5);

let age = 20, hasId = true;
log("Can enter:", age >= 18 && hasId);

let nickname = null;
log("Name:", nickname ?? "Guest");
</script>
Free sign-in required · Google login available

JavaScript Operators Practice Exercises

Check what you learned in “JavaScript Operators”.

/ 3 solved
Fill in the blank

Use the operator that checks equal value AND type.

if (x  5) { }
✓ Correct! Not quite. Try again.
Multiple choice

What is 17 % 5?

✓ Correct! Not quite. Try again.
Code challenge

Log 2 to the power of 10 using the ** operator.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services