JavaScript Tutorial – Assignment Operators
What is JavaScript Assignment Operators?
Assignment operators assign values to JavaScript variables. Here are the five most common assignments in JavaScript:
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 |
= Operator
The =
assignment operator assigns a value to a variable.
+= Operator
The +=
addition operator adds a value to a variable.
-= Operator
The -=
subtraction operator subtracts a value to a variable.
*= Operator
The *=
multiplication operator multiples a value to a variable.
/= Operator
The /=
division operator divides a value to a variable.
There are many more assignment operators in JavaScript, but we will not go over them in this tutorial. You will learn more about them at the later chapers.