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. The typescript also has several compound assignment operators, which is actually shorthand for other operators. List of all such operators are listed below

Table of Content

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

The `=`

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 short hand 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 short hand for

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

## Reference

**Read More**

- Complete Typescript Tutorial
- Typescript Operators
- Arithmetic Operators
- Unary plus / Unary minus Operators
- Increment/Decrement Operators
- Comparison / Relational Operators
- Equality Operator / Strict Equality Operators
- Ternary Conditional Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Nullish coalescing operator
- Comma Operator in Typescript
- Operator Precedence