28/01/2025
Arithmetic operators in JavaScript are used to perform mathematical calculations. Here's a summary:
Basic Operators
1. Addition (+): Adds two numbers.
2. Subtraction (-): Subtracts one number from another.
3. Multiplication (*): Multiplies two numbers.
4. Division (/): Divides one number by another.
5. Modulus (%): Returns the remainder of division.
6. Exponentiation (**): Raises one number to the power of another.
Increment and Decrement:
1. Increment (++): Increases a value by 1.
2. Decrement (--): Decreases a value by 1.
Unary Negation and Plus:
1. Unary Negation (-): Converts a number to its negative.
2. Unary Plus (+): Converts a value to a number (if it isn't already).
Order of Operations (Precedence):
1. Follows PEMDAS (Parentheses, Exponents, Multiplication/Division, Addition/Subtraction) to solve any arithmetic.
Key Points:
1. These operators work with numbers, but strings used with + result in concatenation.
2. NaN (Not-a-Number) is returned for invalid arithmetic.
Thanks for watching