What does "/ =" mean in JavaScript?

I stumbled upon this while looking at the source of some physics animations in JavaScript found here on github where he wrote this

if (this._position < 0) this._position /= 3; 

Fast Google didn’t give anything, does anyone know?

+5
source share
3 answers

The operator of the reduced unit . It is equivalent

 this.position = this.position / 3; 

Division will be performed first, and then the result will be assigned a dividend.

Quote from MDN

The assignment operator splits the variable into the value of the correct operand and assigns the result to the variable.

+8
source

This is the equivalent of dividing += or -=

+1
source

This is the division assignment operator: This performs the following operation: Example:

 var x=10,y=2; x=x/y; /* which is equivalent to x/=y; and returns 5 */ 
+1
source

Source: https://habr.com/ru/post/1242952/


All Articles