CKTIS / JavaScript
Division operator (/)
The / operator computes the quotient of two operands. Number division can return a fraction, while BigInt division discards the fractional part toward zero. Mixing these types and dividing a BigInt by zero throw exceptions.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
dividend / divisorThe / operator divides the left operand (the dividend) by the right operand (the divisor). For Number, the result is also a Number: 7 / 2 produces 3.5, not 3. Floating-point arithmetic has limited precision, so the result is not always exact.
For BigInt, both operands must be BigInt values. The result is truncated toward zero: -7n / 2n produces -3n, not -4n. Division by 0n throws RangeError. Mixing BigInt and Number, as in 7n / 2, throws TypeError; explicitly align the types when needed, remembering that conversion to Number may lose precision.
For Number, division by zero does not throw: 1 / 0 produces Infinity, and 1 / -0 produces -Infinity. Both 0 / 0 and Infinity / Infinity produce NaN; a NaN operand also produces NaN.
Operands undergo numeric conversion before division: "12" / 4 produces 3, while "abc" / 4 produces NaN. The *, /, and % operators share precedence and group from the left: 24 / 4 / 2 means (24 / 4) / 2. Use parentheses to change the grouping.
Examples
console.log(7 / 2);
console.log(String(-7n / 2n));
console.log("12" / 4);
console.log(1 / 0);
console.log(Number.isNaN(0 / 0));
try {
console.log(7n / 2);
} catch (error) {
console.log(error.name);
}
try {
console.log(7n / 0n);
} catch (error) {
console.log(error.name);
}Result
3.5 -3 3 Infinity true TypeError RangeError
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.