Get to know MDN better
The JavaScript exception "BigInt division by zero" occurs when a BigInt is divided by 0n.
The divisor of a division or remainder operator is 0n. In Number arithmetic, this produces Infinity, but there's no "infinity value" in BigInts, so an error is issued. Check if the divisor is 0n before doing the division.
Instead, check if the divisor is 0n first, and either issue an error with a better message, or fallback to a different value, like Infinity or undefined.
This page was last modified on Jul 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.