Widely availableSupported across all major browsers. Safe to use in production.

Overview

The BigInt JavaScript type represents integers of any size, including integers too large for the primitive Number type.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
67
79
68
14
67
14

The BigInt() function returns primitive values of type BigInt.

67
79
68
14
67
14

The BigInt.asIntN() static method truncates a BigInt value to the given number of least significant bits and returns that value as a signed integer.

67
79
68
14
67
14

The BigInt.asUintN() static method truncates a BigInt value to the given number of least significant bits and returns that value as an unsigned integer.

67
79
68
14
67
14

The toString() method of BigInt values returns a string representing the specified BigInt value. The trailing "n" is not part of the string.

67
79
68
14
67
14

The valueOf() method of BigInt values returns the wrapped primitive value of a BigInt object.

67
79
68
14
67
14
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

JAVASCRIPT
const big = 9007199254740993n; // Cannot be represented as a Number
const sum = big + 1n; // 9007199254740994n

typeof big; // 'bigint'

// Cannot perform mixed operations with Number
// big + 1; // TypeError
BigInt(42) + big; // OK

Live demo

large number. Accurate calculation

Number large number, BigInt Useaccurate to calculation..

PreviewFullscreen

Precisioncomparison(number vs Bigint)

is accurate to and comparison.. with is errordifference that outcalculation, BigInt. with Number

PreviewFullscreen

big factorial. Calculation

30! (30 factorial). like large number calculation..

PreviewFullscreen

Use cases

  • Using BigInt

    The BigInt JavaScript type represents integers of any size, including integers too large for the primitive Number type.

Cautions

  • No specific concerns. Stable across all major browsers.

Accessibility

  • When updating the DOM dynamically, announce important changes to assistive technology with aria-live regions.

Powered by web-features