Anna
PRO
last month
Annacountry asked

What does the *= operator mean in programming?

Abhay Jajodia
Expert
last month
Abhay Jajodia answered

Hello Anna, really nice question.

*= is just a shortcut for multiplying a variable by something and then storing the new value back into that same variable. It follows the same pattern as +=, which adds to the existing value.

So instead of writing:

x = x * 5

you can write:

x *= 5

Both do exactly the same thing β€” the second one is just shorter and easier to read once you get used to it.

If you have further questions, I'm here to help.

JS
This question was asked as part of the Learn JavaScript Basics course.