Skip to content
techsnow

JavaScript Basics

Operators

Arithmetic

OperatorExampleResult
+5 + 27
-5 - 23
*5 * 210
/5 / 22.5
%5 % 21 (remainder)
**5 ** 225 (power)

Assignment

let x = 10;
x += 5;  // x = x + 5  → 15
x -= 3;  // 12
x *= 2;  // 24
x++;     // 25

Comparison

OperatorMeaning
===Equal value and type
!==Not equal
> < >= <=Greater / less than
==Equal after converting types (avoid)
console.log(5 === 5);   // true
console.log(5 === "5"); // false
console.log(5 == "5");  // true  (surprising!)

Logical

const age = 20;
const hasTicket = true;
console.log(age >= 18 && hasTicket); // AND → true
console.log(age < 13 || hasTicket);  // OR  → true
console.log(!hasTicket);             // NOT → false