JavaScript BigInt Methods

About This Index
This page is the JavaScript BigInt Methods index for the tutorial track. Each row links to a full guide with syntax, three runnable examples, browser notes, and FAQs.
Learn what a BigInt is and why JavaScript needs it on /js/bigint. Use this page when you need one specific method, such as toString(), toLocaleString(), or BigInt.asIntN().
Static methods are called on BigInt itself: BigInt.asIntN(8, 255n). Instance methods are called on a BigInt value: (255n).toString(16). Writing (255n).asIntN gives undefined, because static methods do not live on the values.
How to Call a BigInt Method
Static methods take the number of bits first and the BigInt second. Instance methods are called with a dot on the value:
// Static methods: call them on BigInt itself
BigInt.asIntN(8, 255n); // -1n
BigInt.asUintN(8, -1n); // 255n
// Instance methods: call them on a BigInt value
(255n).toString(16); // "ff"
(1234567n).toLocaleString("en-US"); // "1,234,567"
Object(5n).valueOf(); // 5n The comments show what each line gives back. A trailing n marks a BigInt result; text in quotes is a string.
JavaScript BigInt Methods Table
All method guides in this JavaScript tutorial series (5 tutorials), grouped by how you call them.
Static methods
2 methodsCalled on BigInt itself. They fit a BigInt into a fixed number of bits, the way a 64-bit or 8-bit integer would store it.
| Method | Description | Tutorial |
|---|---|---|
BigInt.asIntN() | Wrap a BigInt into a signed integer of a given bit width, so it can come out negative. | Open |
BigInt.asUintN() | Wrap a BigInt into an unsigned integer of a given bit width, so it is never negative. | Open |
Instance methods
3 methodsCalled on a BigInt value such as 255n. They turn the BigInt into text or give back the plain BigInt value.
| Method | Description | Tutorial |
|---|---|---|
toString() | Turn a BigInt into a string of digits, in base 10 or any base from 2 to 36. | Open |
toLocaleString() | Format a BigInt for people: separators, currency, or compact notation for a chosen locale. | Open |
valueOf() | Get the plain (primitive) BigInt value, for example out of an Object(5n) wrapper. | Open |
Frequently Asked Questions
Start with BigInt.asIntN()
See how a big number wraps into a signed 8-bit or 64-bit integer, and why 255n becomes -1n.
14 people found this page helpful
