[javascript] *= 연산자
The *=
operator is a compound assignment operator in JavaScript that multiplies a variable by a given value and assigns the result to the variable itself.
Syntax
variable *= value;
Example
Let’s say we have a variable x
with an initial value of 5. If we want to multiply x
by 3 and assign the result back to x
, we can use the *=
operator as follows:
let x = 5;
x *= 3; // Equivalent to: x = x * 3;
// Now, the value of x is 15
Usage
The *=
operator is commonly used when we want to update the value of a variable by multiplying it with another value.
Conclusion
In this post, we discussed the *=
operator in JavaScript, which is a convenient way to perform a multiplication operation and assignment in a single step.
For more information, you can refer to the MDN Web Docs.