Modify-In-Place in JavaScript

Modify-In-Place in JavaScript

The value in the variable "num" can be replaced in another line of code.

i.e.

But, what if you intend to update the value in a variable instead of replacing it?

For instance, you might want to increase the value stored in a variable, so instead of replacing the value, you can easily update it. This process is known as Modify-in-place.

Modify-in-place works with all arithmetic operators.

For addition: "+="

For subtraction: "-="

For multiplication: "*="

For division: "/="

For exponentiation: "**="

For modulus: "%="

In summary, modify-in-place is a process that makes code look neat and shorter.