JavaScript operators are used to perform an operation. There are different types of operators for different uses.
The assignment operator = is used to assign values to JavaScript variables.
The assignment operator + is used to add values together.
y=5;
z=2;
x=y+z;
Arithmetic operators are used to perform arithmetic between variables and/or values.
Given that y=5, the table below explains the arithmetic operators:
| Operatiors | Description |
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| / | Division |
| % | Modulus (remainder of a division) |
| ++ | Increment |
| -- | Decrement |
Assignment operators are used to asign values to variables and/or values.
| Operatiors | Description |
| = | Assign |
| += | Add and assign. For example, x+=y is the same as x=x+y. |
| -= | Subtract and assign. For example, x-=y is the same as x=x-y. |
| *= | Multiply and assign. For example, x*=y is the same as x=x*y. |
| /= | Divide and assign. For example, x/=y is the same as x=x/y. |
| %= | Modulus and assign. For example, x%=y is the same as x=x%y. |
In JavaScript, a string is simply a piece of text.
| Operatiors | Description |
| = | Assign |
| + | Concatenate (join two strings together) |
| += | Concatenate and assign |