Javascript Assignment Operator

The followings are the assignment operator in javascript
1) Simple Assignment
2) Additional Assignment
3) Subtraction Assignment
4) Multiplication Assignment
5) Division Assignment
6) Reminder Assignment

1) Simple Assignment (=)

This operator assigns the right operand value to the left operand.

var a=🍎, b=🍌,c=😻;

2) Additional Assignment (+=)

This operator adds the value of the right operand to a variable and assigns the result to the left operand.


var x = 10;
x += 5;
//OUTPUT: X will be 15

3) Substraction Assignment (-=)

This operator subtracts the value of the right operand from a left operand and assigns the result to the left operand.


var x = 10;
x -= 5;
//OUTPUT: X will be 5

4) Multiplication Assignment (*=)

This operator multiplies left and right operand values and assign the result to the left operand.


var x = 10;
x *= 5;
//OUTPUT: X will be 50

5) Division Operator (/=)

This operator divide left operand value by right operand value and assign the result to the left operand.


var x = 10;
x /= 5;
//OUTPUT: X will be 2

6) Reminder Operator (%=)

The remainder assignment operator divides a left operand by the value of the right operand and assigns the remainder to the left operand


var x = 10;
x %= 5;
//OUTPUT: X will be 0

Leave a Comment