In JavaScript, operators are special symbols or keywords that are used to perform operations on variables and values. They allow you to manipulate data, compare values, or assign values to variables.
=, +=).==, >, <=).&&, ||).&, |).++, decrement -).if-else statements (e.g., condition ? expr1 : expr2)....).null or undefined (e.g., ??).Used to perform mathematical calculations.
| Operator | Description | Example |
|---|---|---|
+ |
Addition | 5 + 2 → 7 |
- |
Subtraction | 5 - 2 → 3 |
* |
Multiplication | 5 * 2 → 10 |
/ |
Division | 5 / 2 → 2.5 |
% |
Modulus (Remainder) | 5 % 2 → 1 |
** |
Exponentiation | 2 ** 3 → 8 |
Used to assign values to variables.