Operators in JavaScript
Operators are symbols or keywords used to perform operations on values and
variables. JavaScript supports a variety of operators for arithmetic, comparison,
logical operations, and more.
1. Arithmetic Operators
Used for basic mathematical operations.
Operator Description Example Result
+ Addition 5+2 7
- Subtraction 5-2 3
* Multiplication 5*2 10
/ Division 5/2 2.5
% Modulus (remainder) 5%2 1
++ Increment let a = 5; a+ 6
+;
-- Decrement let a = 5; a--; 4
2. Assignment Operators
Used to assign values to variables.
Operator Description Example Equivalent To
= Assignment x = 10 x = 10
+= Addition assignment x += 5 x=x+5
-= Subtraction assignment x -= 5 x=x-5
*= Multiplication assignment x *= 5 x=x*5
/= Division assignment x /= 5 x=x/5
%= Modulus assignment x %= 5 x=x%5
Operators are symbols or keywords used to perform operations on values and
variables. JavaScript supports a variety of operators for arithmetic, comparison,
logical operations, and more.
1. Arithmetic Operators
Used for basic mathematical operations.
Operator Description Example Result
+ Addition 5+2 7
- Subtraction 5-2 3
* Multiplication 5*2 10
/ Division 5/2 2.5
% Modulus (remainder) 5%2 1
++ Increment let a = 5; a+ 6
+;
-- Decrement let a = 5; a--; 4
2. Assignment Operators
Used to assign values to variables.
Operator Description Example Equivalent To
= Assignment x = 10 x = 10
+= Addition assignment x += 5 x=x+5
-= Subtraction assignment x -= 5 x=x-5
*= Multiplication assignment x *= 5 x=x*5
/= Division assignment x /= 5 x=x/5
%= Modulus assignment x %= 5 x=x%5