Operators & Expressions
Learn arithmetic, comparison, and logical operators to perform calculations and make decisions. This is a foundational concept in programming and web interactivity that professional developers rely on daily. The explanations below are written to be beginner-friendly while covering the depth and nuance that comes from real-world JavaScript experience. Take your time with each section and practice the examples
20 min•By Priygop Team•Last updated: Feb 2026
JavaScript Operators
Operators perform operations on values. Arithmetic operators do math. Comparison operators compare values and return true or false. Logical operators combine conditions. Assignment operators assign values to variables.
Types of Operators
- Arithmetic: + - * / % ** (addition, subtraction, multiply, divide, remainder, power)
- Assignment: = += -= *= /= (assign and update)
- Comparison: == === != !== > < >= <= (compare, return boolean)
- Logical: && (AND), || (OR), ! (NOT)
- String: + concatenates strings: 'Hello' + ' World'
- === is strict equality (checks value AND type) — a critical concept in programming and web interactivity that you will use frequently in real projects
- == is loose equality (only checks value, avoid it)
Operators Example
Example
// Arithmetic
let a = 10, b = 3;
console.log(a + b); // 13
console.log(a - b); // 7
console.log(a * b); // 30
console.log(a / b); // 3.333...
console.log(a % b); // 1 (remainder)
console.log(a ** 2); // 100 (power)
// Comparison (returns true/false)
console.log(10 > 5); // true
console.log(10 === 10); // true
console.log(10 === "10"); // false (strict!)
// Logical
console.log(true && false); // false
console.log(true || false); // true
console.log(!true); // false
// Assignment shorthand
let score = 100;
score += 10; // score = score + 10 = 110
console.log(score);Try It Yourself: Calculator
Try It Yourself: CalculatorJavaScript
JavaScript Editor
✓ ValidTab = 2 spaces
JavaScript|15 lines|522 chars|✓ Valid syntax
UTF-8