An assignment operator requires two operands. The value of the right operand is assigned to the left operand. The sign = denotes the simple assignment operator. JavaScript also has several compound assignment operators, which is actually shorthand for other operators. A list of all such operators are listed below.

Table of Contents

## List of Assignment operators

Name | Syntax | Meaning |
---|---|---|

Assignment | x = y | x = y |

Addition assignment | x += y | x =x+ y |

Subtraction assignment | x -= y | x = x - y |

Multiplication assignment | x *= y | x = x * y |

Division assignment | x /= y | x = x / y |

Remainder assignment | x %= y | x = x % y |

Exponentiation assignment | x **= y | x = x ** y |

Left shift assignment | x <<= y | x = x << y |

Right shift assignment | x >>= y | x = x >> y |

Unsigned right shift assignment | x >>>= y | x = x >>> y |

Bitwise AND assignment | x &= y | x = x & y |

Bitwise XOR assignment | x ^= y | x = x ^ y |

Bitwise OR assignment | x |= y | x = x | y |

Logical AND assignment | x &&= y | x && (x = y) |

Logical OR assignment | x ||= y | x || (x = y) |

Logical nullish assignment | x ??= y | x ?? (x = y) |

## Simple Assignement Operator

An **=** assignment operator assigns the value of the right-hand operand to the left-hand variable.

1 2 3 4 5 6 7 |
var x = 25; var y = 25*100; var z = x+y; |

## Compound Assignment Operators

All operators except = listed in the table above are compound assignment operators. They are actually shorthand notations

For Examples

The Addition assignment `+=`

operator adds a value to a variable.

1 2 3 4 |
var x = 25; x +=25; //50; |

is actually shorthand for

1 2 3 4 |
var x= 25; x = x + 25; //50 |

## Reference

**Read More**

- JavaScript Tutorial
- JavaScript Operators
- Arithmetic Operators
- Unary plus (+) & Unary minus (-)
- Increment & Decrement Operators
- Comparison or Relational Operators
- Strict Equality & Loose Equality Checker
- Ternary Conditional Operator
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Nullish Coalescing Operator
- Comma Operator
- Operator Precedence