# JavaScript: Assignment Operators

## Assignment Operators

An assignment operator assigns a value to its left operand based on the value
of its right operand. The first operand must be a variable and basic assignment operator is equal (=), which assigns
the value of its right operand to its left operand. That is, a = b assigns the value of b to a.

In addition to the regular assignment operator "=" the other assignment operators are shorthand for standard operations, as shown
in the following table.

Shorthand |
Expression |
Description |
---|---|---|

a +=b | a = a + b | Adds 2 numbers and assigns the result to the first. |

a -= b | a = a - b | Subtracts 2 numbers and assigns the result to the first. |

a *= b | a = a*b | Multiplies 2 numbers and assigns the result to the first. |

a /=b | a = a/b | Divides 2 numbers and assigns the result to the first. |

a %= b | a = a%b | Computes the modulus of 2 numbers and assigns the result to the first. |

a<<=b | a = a<<b | Performs a left shift and assigns the result to the first operand. |

a>>=b | a = a>>b | Performs a sign-propagating right shift and assigns the result to the first operand. |

a>>>=b | a = a>>>b | Performs a zero-fill right shift and assigns the result to the first operand. |

a&= b | a = a&b | Performs a bitwise AND and assigns the result to the first operand. |

a^= b | a = a^b | Performs a bitwise XOR and assigns the result to the first operand. |

a |=b | a = a|b | Performs a bitwise OR and assigns the result to the first operand. |

**Previous: ** JavaScript: Arithmetic Special Operators (%, ++, --, - )

**Next:** JavaScript: Bitwise Operators

Test your Programming skills with w3resource's quiz.

**Weekly Trends**- 100 Python Projects for Beginners with solution
- Mastering NumPy: 100 Exercises with solutions
- SQL Tutorial
- SQL Inner Join
- Python Exercises, Practice, Solution
- Python Interview Questions and Answers: Comprehensive Guide
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript HTML Form Validation
- Java Collection Exercises