# Tutorial

## JavaScript Assignment Operators

An assignment operator assigns a value to its left operand based on the value of its right operand. The simple assignment operator is equal (`=`), which assigns the value of its right operand to its left operand. That is, `x = y` assigns the value of `y` to `x`.

There are also compound assignment operators that are shorthand for the operations listed in the following table:

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
>>= 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

## Assignment Examples

The `=` assignment operator assigns a value to a variable.

### EXAMPLE ❯

The `+=` assignment operator adds a value to a variable.

The addition assignment operator ( += ) adds the value of the right operand to a variable and assigns the result to the variable.

The types of the two operands determine the behavior of the addition assignment operator.

### EXAMPLE ❯

The `-=` assignment operator subtracts a value from a variable.

The subtraction assignment operator ( -= ) subtracts the value of the right operand from a variable and assigns the result to the variable.

### EXAMPLE ❯

The `*=` assignment operator multiplies a variable.

The multiplication assignment operator ( *= ) multiplies a variable by the value of the right operand and assigns the result to the variable.

### EXAMPLE ❯

The `/=` assignment divides a variable.

The division assignment operator ( /= ) divides a variable by the value of the right operand and assigns the result to the variable.

### EXAMPLE ❯

The `%=` assignment operator assigns a remainder to a variable.

The remainder assignment operator ( %= ) divides a variable by the value of the right operand and assigns the remainder to the variable.