JavaScript /= Division assignment Operator
The division assignment operator (/=) divides a variable by a value and stores the result.
Description
The division assignment operator /= divides the variable by the right operand and assigns the result. x /= y is short for x = x / y.
Division by zero doesn't throw: x /= 0 leaves x as Infinity, -Infinity or NaN, so check the divisor first when it could be zero. The result isn't rounded; wrap it in Math.floor() or Math.trunc() afterwards if you need a whole number.
Compound assignment operators are evaluated from right to left like plain assignment, and the expression itself returns the new value, although using that value inside a larger expression usually makes code harder to read. The left side must be something that can be assigned to: a variable declared with let or var, an object property or an array element. Using one on a const throws a TypeError.
Properties
- Operator
/=- Category
- Assignment
- Precedence
- 2 (1 is lowest, 18 is highest)
- Associativity
- right-to-left
Syntax
x /= yExample
Browser Support
The following information will show you the current browser support for the /= operator. Hover over a browser icon to see the version that first introduced support for this operator.
Desktop





Tablets & Mobile





