Image not visible
Chapter - 5 : Assignment Operators

#1 "=" Equal

It is used to assign value to the variable. It assigns the value of the right operand to the left operand.
Try it by checking the following numbers in the code a = 2
Console.log(a)

#2 "+=" Add and Assign

It adds right operand to the left operand and then assign the value to the left operand for example
x += 2 is equivalent to x = x + 2
Try it by checking the following numbers in the code
a=10
a += 2
console.log(a)

#3 "-=" Subtract and Assign

It Subtract right operand from the left operand and then assign the value to the left operand. for example
x -= 2 is equivalent to x = x - 2
Try it by checking the following numbers in the code
a = 10
a -= 2
console.log(a)

#4 "*=" Multiply and Assign

It Multiply right operand with the left operand and then assign the value to the left operand. for example
x *= 2 is equivalent to x = x * 2
Try it by checking the following numbers in the code
a=10
a *= 2
console.log(a)

#5 "/=" Divide and Assign

It Divides the right operand with the left operand and then assign the value to the left operand. for example
x /= 2 is equivalent to x = x / 2
Try it by checking the following numbers in the code
a = 10
a /= 2
console.log(a)

#6 "%=" modulus and Assign

It Divides the right operand with the left operand and then assign the remainder of the operation to the left operand. for example
x %= 2 is equivalent to x = x % 2
Try it by checking the following numbers in the code
a = 10
a %= 3
console.log(a)