Assignment Operators in JavaScript

There are following assignment operators which JavaScript supports.

JavaScript assignment Operators

Assignment operator are basically used to perform assign values.

Operator Example Same as
= x = y x = y
+= x += y x = x + y
-= x -= y x = x - y
*= x *= y x = x * y
/= x /= y x = x / y
%= x %= y x = x % y
**= x **= y x = x ** y

Example of assignment

The (=) operator is used for assign value.

var a = 6;
var b = 3;


Example of Adding with assign

The (+=) operator is used for adds value while assigning the value to variable.

var a += 6;
var b += 3;


Example of subtraction with assign

The (-=) operator is used for subtract value while assigning the value to variable.

var a -= 6;
var b -= 3;


Example of Multiplying with assign

The (*=) operator is used for multiply the value while assigning the value to variable.

var a *= 6;
var b *= 3;


Example of Dividing with assign

The (/=) operator is used for dividing the value while assigning the value to variable.

var a /= 6;
var b /= 3;


Example of Remainder with assign

The (%=) operator is used for division remainder the value while assigning the value to variable.

var a %= 6;
var b %= 3;








The Best

Comment here

If you have any query, if you want to know something about any of technical course related to computer science field, if you have any suggestion about relevant to uploaded content or if you anything wrong here (any mistake in content) than please contact us. Keep in mind, comment should be according to community guidelines.