Multiplication Assignment Operator in JavaScript



Multiplication Assignment Operator

In JavaScript, Multiplication assignment operator takes two operands, multiplies the value in right operand to that of the left operand, and assigns the result back to the left operand.

Syntax

*= symbol is used for multiplication assignment operator.

a *= 5  //equivalent to a = a * 5
a *= b  //equivalent to a = a * b

Examples

1. Multiply a with 5 and assign the result back to a.

var a = 4;
a *= 5;
console.log(a);

2. Multiply a with value in b and assign the result back to a.

var b = 7;
var a = 4;
a *= b;
console.log(a);