JavaScript / Division Operator
The division operator (/) divides one number by another. Dividing by zero gives Infinity rather than an error.
Description
The division operator / divides the left operand by the right. JavaScript has no separate integer division: 7 / 2 is 3.5, so use Math.trunc() or Math.floor() for a whole-number result. Dividing a non-zero number by zero gives Infinity or -Infinity, and 0 / 0 gives NaN; neither throws an error. With BigInts, division rounds towards zero.
Division follows the usual floating point rules, so some results can't be represented exactly: 1 / 3 is 0.3333333333333333. When displaying results, format them with toFixed() or Intl.NumberFormat. To check whether one number divides evenly into another, use the remainder operator: a % b === 0. Division and multiplication have the same precedence and are evaluated left to right, so 8 / 2 * 4 is 16.
Operands are converted to numbers first, so '10' / '4' is 2.5, and values that can't be converted give NaN. Dividing BigInts gives a BigInt, discarding any remainder, and dividing a BigInt by 0n throws a RangeError instead of returning Infinity. The compound form x /= y divides a variable in place.
Properties
- Operator
/- Category
- Arithmetic
- Precedence
- 12 (1 is lowest, 18 is highest)
- Associativity
- left-to-right
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





