Skip to content
Related Articles

Related Articles

JavaScript BigInt Complete Reference

Improve Article
Save Article
  • Last Updated : 15 Nov, 2022
Improve Article
Save Article

BigInt is an inbuilt object in JavaScript that provides a way to represent whole numbers larger than 253-1 which is the largest number that can represent with the Number primitive. It is represented by the MAX_SAFE_INTEGER constant.

The complete methods of JavaScript BigInt object are listed below:

Example: This example creates a BigInt by appending n at the end of the number.

Javascript




<script>
    // Decimal format
    var bigNum = 123422222222222222222222222222222222222n
    console.log(bigNum)
      
    // Hexadecimal format
    var bigHex = 0x1ffffffeeeeeeeeefn
    console.log(bigHex)
      
    // Binary format
    var bigBin = 0b1010101001010101001111111111111111n
    console.log(bigBin)
</script>

Output:

123422222222222222222222222222222222222n
VM41:6 36893488074118328047n
VM41:10 11430854655n

1. Static Methods

JavaScript BigInt Static Methods

Descriptions

JavaScript BigInt.asIntN() MethodThe BigInt.asIntN() method is an inbuilt method in JavaScript that is used to wrap a BigInt value to a signed integer between -2width-1 and 2width-1-1.
JavaScript BigInt.asUintN() MethodThe BigInt.asUintN() method is an inbuilt method in JavaScript that is used to wrap a BigInt value to an unsigned integer between 0 and 2width-1.

2. Instance Methods

JavaScript BigInt Instance Methods

Descriptions

JavaScript BigInt.prototype.toLocaleString() MethodThe BigInt.prototype.toLocaleString() method is an inbuilt method in JavaScript which is used to return a string with a language-sensitive representation of this BigInt.
JavaScript BigInt.prototype.toString() MethodThe BigInt.prototype.toString() method is an inbuilt method in JavaScript that is used to return a string representing the specified BigInt object.
JavaScript BigInt.prototype.valueOf() MethodThe BigInt.prototype.toString() method is an inbuilt method in JavaScript that is used to return the wrapped primitive value of a BigInt object.
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!