Advertisement
Intermediate JavaScript, Numbers, Math & BigInt

What is BigInt and how do you create one?

Short answer

BigInt is a separate numeric type that can represent arbitrarily large integers exactly, with no upper precision limit like regular Numbers. Create one by appending 'n' to an integer literal or calling BigInt(value).

Save JavaScript mock interview
Advertisement
AModel answer
BigInt is a separate numeric type that can represent arbitrarily large integers exactly, with no upper precision limit like regular Numbers. Create one by appending 'n' to an integer literal or calling BigInt(value).
const big = 9007199254740993n;
const big2 = BigInt('9007199254740993');
console.log(big === big2); // true
Real-world example
Precisely representing 64-bit database IDs, cryptographic values, or very large financial totals.
Likely follow-ups
  • Can you mix BigInt and Number directly in arithmetic expressions?
Related topics