By the end of this class, students will be able to:
Operators are symbols that perform actions on values (operands).
For example:
let a = 10;
let b = 5;
let sum = a + b;
console.log(sum); // 15
Here:
+ is an operator.a and b are operands.| Category | Example Symbols | Purpose |
|---|---|---|
| Arithmetic | +, -, *, /, %, ** |
Perform math operations |
| Assignment | =, +=, -=, *=, /= |
Assign or update values |
| Comparison | ==, ===, !=, !==, >, <, >=, <= |
Compare two values |
| Logical | &&, ` |
|
| String | + |
Combine strings |
| Increment / Decrement | ++, -- |
Increase or decrease values |
| Ternary | condition ? true : false |
Short form of if-else |
These perform basic math:
let a = 10;
let 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 ** b); // 1000 (10³)