MDN doc

BigInt is a built-in object that provides a way to represent whole numbers larger than 2^53 - 1, which is the largest number JavaScript can reliably represent with the Number primitive and represented by the Number.MAX_SAFE_INTEGER constant. BigInt can be used for arbitrarily large integers.

Difference:

  • BigInt cannot be used with methods in the built-in Math object and cannot be mixed with instances of Number in operations
  • Because coercing between Number and BigInt can lead to loss of precision, it is recommended to only use BigInt when values greater than 2^53 are reasonably expected and not to coerce between the two types.
Answer from Dhruvil21_04 on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › BigInt
BigInt - JavaScript | MDN
BigInt values represent integer values which are too high or too low to be represented by the number primitive.
🌐
W3Schools
w3schools.com › js › js_bigint.asp
JavaScript BigInt
JS Examples JS HTML DOM JS HTML ... Prep JS Bootcamp JS Certificate JS Reference ... BigInt is a JavaScript data type for handling and storing big integer values....
🌐
Reddit
reddit.com › r/learnprogramming › js data types - number vs bigint questions
r/learnprogramming on Reddit: JS Data Types - number vs BigInt questions
October 13, 2025 -

Hi there, I'm learning data types in javascript. Messing around. I used these variables.

let x = 15;
let y = 123456789999;

typeof shows them both as numbers. So it got me thinking...

  1. Where does number end and bigint begin? I went as high as let y = 1234567899999999999999999999999999999; and it was still a number. When I put an n on the end, it's bigint, so

  2. What does n stand for or translate to? Is it infinity, or does it make it some continuous number? I thought number and bigint were separate DTs for memory purposes, so

  3. Is there an explicit way to declare a number vs bigint? I want to see what happens if I declare a bigint as a number and vice versa. But number is reserved, so I can't "let number = 123456789999n".

  4. Lastly, does anyone use bigint in programming, I mean, does it serve a practical purpose?

Thanks

Top answer
1 of 2
4
Where does number end and bigint begin? It's not like values below some threshold are numbers, and above that threshold they're bigints. They're two entirely different ways of representing numeric values. JavaScript's "number" type is a floating point type , which means that numbers are rounded to about 53 significant binary digits (which is roughly equivalent to 16 significant decimal digits). So you can store very large numbers, but your results will be inexact. Try calculating 10000000000000001 - 10000000000000000 and see what you get. What does n stand for or translate to? It's just syntax that tells the JS parser to interpret your numeric constant as a BigInt instead of a Number, so that it will be represented exactly. Is it infinity, or does it make it some continuous number? No idea what you mean by this. Is there an explicit way to declare a number vs bigint? Yes, like I said, that's what the n suffix is for. I want to see what happens if I declare a bigint as a number and vice versa. This doesn't make any sense in JavaScript. Variables don't have types; only values have types. A variable could store a Number value, or a BigInt value, but it has to be one or the other. It can't be both at the same time. But number is reserved, so I can't "let number = 123456789999n". The name of your variable is just a name. It doesn't have any connection to the data type that you store in the variable. Lastly, does anyone use bigint in programming, I mean, does it serve a practical purpose? Well, any time you want to do exact integer arithmetic without rounding. Just as one example, cryptographic algorithms often do arithmetic on integers with hundreds of digits. The exact value of those integers is crucial, and any rounding or inaccuracy would completely ruin the output.
2 of 2
2
JS' BigInt type is a string based number. So it has no standardized lower and upper limits. But it does have those limits depending on its implementation. e.g. both Firefox (SpiderMonkey JS engine) and Chromium (V8 JS engine), have different lower/upper limit in terms of number of digits. The n is just a type specifier for BigInt much like the "/' for String. i.e. 123 is a number (the default), "123" is a string, and 123n is a BigInt. BigInt is as it's design for. To handle very big number. This is expecially useful for exact scientific measurements. Both in small and large scale, where the number of digits is greater than 15 - which normal JS number type can't store or can't accurately store.
🌐
Smashing Magazine
smashingmagazine.com › 2019 › 07 › essential-guide-javascript-newest-data-type-bigint
The Essential Guide To JavaScript’s Newest Data Type: BigInt — Smashing Magazine
Unluckily, transpiling BigInt is an extremely complicated process, which incurs hefty run-time performance penalty. It’s also impossible to directly polyfill BigInt because the proposal changes the behavior of several existing operators. For now, a better alternative is to use the JSBI library, which is a pure-JavaScript implementation of the BigInt proposal.
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › miscellaneous
BigInt
But JSBI works with numbers as with bigints internally, emulates them closely following the specification, so the code will be “bigint-ready”.
🌐
DEV Community
dev.to › fvictorio › a-comparison-of-bignumber-libraries-in-javascript-2gc5
A comparison of BigNumber libraries in JavaScript - DEV Community
November 28, 2020 - Finally I'll give you my advice on which one to use (spoiler alert: it's big.js). The following table shows the libraries I picked and some aspects of each one. There are a lot of other things you might want to consider, like their API, performance, supported operations, etc., but this should give you a place to start. All of them support integer values, but decimal.js, by design, can lose precision (more on this later). Both BigInteger.js and JSBI can act as some sort of polyfill for the ECMAScript BigInt proposal, although their approaches differ.
Top answer
1 of 2
3

Those are not necessarily one recommendation. It can easily be two interrelated ones.

  1. Only use BigInt for integers that reasonably may exceed 2^53.

    A BigInt isn't a general-purpose number. It's specifically for large integers, hence the name. They're best when used in specific, isolated cases where you expect large integers may well appear, in no small part because in other cases, the design goals (including preventing accidental losses of precision) make the type too restrictive to be useful. You can't do Math stuff with them, you can't mix types, etc. For numbers you know will be less than 2^53, a Number will be far less restricted (read: more useful), and generally much faster and easier to work with.

    (For an example of the performance difference, see https://jsperf.com/bigint-vs-number/5. The test at first showed a 1% difference at first in Chrome, but once your values aren't effectively constant, it's harder to hide the differences, and performance drops drastically.)

  2. Don't convert between BigInt and Number.

    The entire point of BigInt is to serve as an arbitrary-precision integer. Converting to a Number takes all those extra bits you asked for, and shoehorns them into a double-precision float. Only the most significant 52+1 bits will be preserved. If you can tolerate that happening, you probably don't need a BigInt in the first place.

They're interrelated in that the temptation to convert gets greater the more you deal with BigInts that would be better off as Numbers and bump into the limitations of the type. The thing is, those limitations are for the most part quite intentional. You can better avoid those limitations by not using BigInt than by sidestepping them and throwing bits away.

2 of 2
3

As far as I understand it, there is no implicit type coercion, only explicit type cast.

Indeed.

Should I not use BigInt, when my numbers are "small"? I see no good reason to avoid it.

I'm not a heavy user of BigInt but I agree with your remark: if you rely on integers in a range that is beyond Number.MAX_SAFE_INTEGER, you should definitely want to use BigInts, for large as well as "small" integers.

Actually I guess the disclaimer in the MDN documentation should be interpreted in the other way around: if you need large integers, try your best not to use type casts, namely, don't use Numbers in the first place.

This is by the way what suggests that other paragraph in the MDN documentation:

Be careful coercing values back and forth, however, as the precision of a BigInt may be lost when it is coerced to a Number.

Find elsewhere
🌐
npm Trends
npmtrends.com › big-integer-vs-big.js-vs-bigint-vs-biginteger-vs-bignumber.js-vs-decimal.js-vs-int64
big-integer vs big.js vs bigint vs biginteger vs bignumber.js vs decimal.js vs int64 | npm trends
Comparing trends for big-integer 1.6.52 which has 13,129,030 weekly downloads and 1,127 GitHub stars vs. big.js 7.0.1 which has 22,741,896 weekly downloads and 5,145 GitHub stars vs. bigint 0.4.2 which has 32 weekly downloads and unknown number of GitHub stars vs. biginteger 1.0.3 which has 4,882 weekly downloads and 186 GitHub stars vs. bignumber.js 9.3.1 which has 22,456,557 weekly downloads and 6,959 GitHub stars vs. decimal.js 10.6.0 which has 30,839,443 weekly downloads and 7,089 GitHub stars vs. int64 0.0.5 which has 761 weekly downloads and 0 GitHub stars.
🌐
Webdevtutor
webdevtutor.net › blog › javascript-bigint-vs-bigint
JavaScript Bigint vs Bigint: A Comprehensive Comparison
In conclusion, both JavaScript's ... you need precise integer arithmetic and compatibility with modern browsers and Node.js, JavaScript's built-in BigInt type may be the better choice....
🌐
MeasureThat
measurethat.net › Benchmarks › Show › 26506 › 0 › bigint-vs-bignumberjs-vs-bigjs-vs-decimaljs
Benchmark: bigint vs. bignumber.js vs. big.js vs. decimal.js - MeasureThat.net
bignumber.js vs. big.js vs. [email protected] (I) bigint vs. bignumber.js vs. big.js vs. break_infinity.js · Comments · × · Do you really want to delete benchmark? Cancel Delete · × · FAQ: FAQ · Source code: GitHub/MeasureThat.net · Report issues: MeasureThat.net/Issues ·
🌐
Tektutorialshub
tektutorialshub.com › home › javascript › bigint vs number in javascript
BigInt Vs Number in JavaScript - Tektutorialshub
January 30, 2022 - But if the bigInt number is larger than Number.MAX_SAFE_INTEGER then you will loose precision · let numVar=100; let bigVar= 100n; console.log(numVar+ Number(bigVar)); //200 · Convert the number to bigInt, but if the number is a decimal number, then you will loose the precision again as bigInt is integer and not decimal.
🌐
Medium
medium.com › glovo-engineering › cracking-the-code-js-bigint-and-the-art-of-future-proofing-your-app-2ef6d00f5d0c
Cracking the Code: JS, BigInt, and the Art of Future-Proofing Your App | by Victor Borisov | The Glovo Tech Blog | Medium
November 29, 2023 - Due to the limitations, number ... floating point numbers. We can use BigInt type in JS instead of the `number`, it allows only to work with integers, but it can safely work with much bigger ......
🌐
MeasureThat
measurethat.net › Benchmarks › Show › 19007 › 0 › js-bigint-big-number-performance-v2
Benchmark: JS BigInt big number performance v2 - MeasureThat.net
JS BigInt big number performance vx · JS BigInt big number performance vx4 · parseInt vs Number BigInts · Comments · × · Do you really want to delete benchmark? Cancel Delete · × · FAQ: FAQ · Source code: GitHub/MeasureThat.net · Report issues: MeasureThat.net/Issues ·
🌐
npm Trends
npmtrends.com › big-integer-vs-big.js-vs-bigint-vs-bignumber.js-vs-decimal.js-vs-int64
big-integer vs big.js vs bigint vs bignumber.js vs decimal.js vs int64 | npm trends
Comparing trends for big-integer 1.6.52 which has 14,202,075 weekly downloads and 1,126 GitHub stars vs. big.js 7.0.1 which has 26,217,295 weekly downloads and 5,141 GitHub stars vs. bigint 0.4.2 which has 148 weekly downloads and unknown number of GitHub stars vs. bignumber.js 9.3.1 which has 23,984,040 weekly downloads and 6,956 GitHub stars vs. decimal.js 10.6.0 which has 33,596,513 weekly downloads and 7,074 GitHub stars vs. int64 0.0.5 which has 875 weekly downloads and 0 GitHub stars.
🌐
npm Trends
npmtrends.com › big-integer-vs-big.js-vs-bigint-vs-biginteger-vs-bn.js-vs-decimal.js-vs-int64
big-integer vs big.js vs bigint vs biginteger vs bn.js vs decimal.js vs int64 | npm trends
Comparing trends for big-integer 1.6.52 which has 12,759,949 weekly downloads and 1,126 GitHub stars vs. big.js 7.0.1 which has 24,368,463 weekly downloads and 5,119 GitHub stars vs. bigint 0.4.2 which has 367 weekly downloads and unknown number of GitHub stars vs. biginteger 1.0.3 which has 4,542 weekly downloads and 186 GitHub stars vs. bn.js 5.2.2 which has 37,378,130 weekly downloads and 1,227 GitHub stars vs. decimal.js 10.6.0 which has 31,451,577 weekly downloads and 7,003 GitHub stars vs. int64 0.0.5 which has 618 weekly downloads and 0 GitHub stars.
🌐
V8
v8.dev › features › bigint
BigInt: arbitrary-precision integers in JavaScript · V8
BigInts are a new numeric primitive in JavaScript that can represent integers with arbitrary precision. This article walks through some use cases and explains the new functionality in Chrome 67 by comparing BigInts to Numbers in JavaScript.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › difference-between-bigint-and-number-in-javascript
Difference Between BigInt and Number in JavaScript - GeeksforGeeks
July 23, 2025 - In JavaScript, BigInt and Number ... The BigInt is suitable for the scenarios demanding the precise and large integer values while Number is sufficient for the general arithmetic and most everyday calculations...