JS Assignment
JavaScript assignment operators are used to assign values to JavaScript variables.
JavaScript assignment operators are used to assign values to JavaScript variables.
The Assignment Operator (=)
The Simple Assignment Operator (=) assigns a value to a variable.
Preview
Addition Assignment (+=)
The Addition Assignment Operator (+=) adds a value to a variable and assigns the new value to the variable.
Preview
Subtraction Assignment (-=)
The Subtraction Assignment Operator (-=) subtracts a value from a variable.
Preview
Multiplication and Division Assignment
The Multiplication Assignment Operator (*=) multiplies a variable. The Division Assignment Operator (/=) divides a variable.
Preview
List of Assignment Operators
| Operator | Example | Same As |
|---|---|---|
= | x = y | x = y |
+= | x += y | x = x + y |
-= | x -= y | x = x - y |
*= | x *= y | x = x * y |
/= | x /= y | x = x / y |
%= | x %= y | x = x % y |
**= | x **= y | x = x ** y |