Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt

Use this file to discover all available pages before exploring further.

The division operator (/) is a binary arithmetic operator that calculates the quotient of its left operand (dividend) divided by its right operand (divisor). For standard numbers, which are implemented as double-precision 64-bit floating-point values (IEEE 754), the division operator yields a floating-point result, retaining fractional components rather than implicitly truncating to an integer.
dividend / divisor

Type Coercion

If either operand is not of type Number or BigInt, JavaScript evaluates the expression by implicitly coercing the operands using the abstract ToNumeric operation. The distinction of using ToNumeric rather than ToNumber is critical because ToNumeric allows object wrappers of BigInts (e.g., Object(5n)) to be correctly unboxed to BigInt primitives rather than being forced into Number types. If an operand cannot be successfully coerced into a valid numeric value, the operation evaluates to NaN.
10 / "2"         // 5 (String "2" is coerced to Number 2)
10 / true        // 10 (Boolean true is coerced to Number 1)
10 / null        // Infinity (null is coerced to Number 0)
10 / "text"      // NaN ("text" coerces to NaN)
10n / Object(2n) // 5n (Object wrapper unboxed to BigInt via ToNumeric)

Floating-Point Exceptions and Special Values

For standard Number types, JavaScript does not throw a runtime exception for division by zero. Instead, it adheres to IEEE 754 specifications for special numeric values:
  • Division by Zero: Dividing a non-zero positive number by 0 yields Infinity. Dividing a non-zero negative number by 0 yields -Infinity.
  • Zero by Zero: Dividing 0 by 0 yields NaN.
  • Infinity: Dividing any finite number by Infinity or -Infinity yields 0 or -0. Dividing Infinity by Infinity yields NaN.
 5 / 0               // Infinity
-5 / 0               // -Infinity
 0 / 0               // NaN
 5 / Infinity        // 0
 Infinity / Infinity // NaN

BigInt Evaluation

When both operands are BigInt primitives, the / operator performs integer division. The result is always truncated towards zero, discarding any fractional remainder. Unlike standard Number evaluation, dividing a BigInt by 0n explicitly throws a RangeError.
10n / 3n      // 3n
-10n / 3n     // -3n
5n / 0n       // RangeError: Division by zero
Attempting to mix BigInt and Number types across the / operator without explicit casting will throw a TypeError, as JavaScript does not implicitly coerce between these two distinct numeric types.
10n / 2       // TypeError: Cannot mix BigInt and other types
Master JavaScript with Deep Grasping Methodology!Learn More