Assignment Operators
What are Assignment Operators
Generally in programming, assignment operators are those operators(symbols) that are used to assign a value to a variable.
Basic Assignment operator
Basic assignment operator represented by =
assigns the value on the its right to a variable on its left
Example
Addition Assignment operator
Addition assignment operator symbolised by +=
adds the operand(value) on its right to the variable or property on its left, and assigns the result to the variable or property on its left.
Example
Subtraction Assignment operator
Subtraction assignment operator symbolised by -=
subtracts the operand(value) on its right from the variable or property on its left, and assigns the result to the variable or property on its left.
Example
Multiplication Assignment operator
Multiplication assignment operator symbolised by *=
multiply the operand(value) on its right by the variable or property on its left, and assigns the result to the variable or property on its left.
Example
Division Assignment operator
Division assignment operator represented by /=
divides the variable or object on the its left by the operand(value) on its right, and then assigns the result to the variable or object on its left
Example
Floor Division Assignment operator
Floor-Division assignment operator represented by //=
divides the variable or object on the its left by the operand(value) on its right, and then assigns the result to the variable or object on its left
Example
Modulus Assignment operator
Division assignment operator represented by %=
divides the variable or object on the its left by the operand(value) on its right, and then assigns the result to the variable or object on its left