JavaScript Tutorial - Operators
๐ข Operators - Calculations & Comparisons
๐ Real Life Mein:
๐งฎ Calculator operations:
โ Shopping bill = item1 + item2 + item3
๐ฐ Discount = price - (price ร 0.10)
๐ Average marks = total / subjects
๐ Age check = age >= 18
๐ Arithmetic Operators
| Operator | Operation | Example | Result |
|---|---|---|---|
| + | Addition | 10 + 5 | 15 |
| - | Subtraction | 10 - 5 | 5 |
| * | Multiplication | 10 * 5 | 50 |
| / | Division | 10 / 2 | 5 |
| % | Modulus (remainder) | 10 % 3 | 1 |
| ++ | Increment | x++ | x = x + 1 |
| -- | Decrement | x-- | x = x - 1 |
๐ Comparison Operators
| Operator | Meaning | Example |
|---|---|---|
| == | Equal to (value) | 5 == "5" โ true |
| === | Strict equal (value + type) | 5 === "5" โ false |
| != | Not equal | 5 != 3 โ true |
| > | Greater than | 10 > 5 โ true |
| < | Less than | 5 < 10 โ true |
Example
let sum = 10 + 5;
let isEqual = (10 == 10);