Skip to content
Related Articles
Open in App
Not now

Related Articles

JavaScript BigInt Complete Reference

Improve Article
Save Article
  • Last Updated : 06 Jan, 2023
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 the 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

JavaScript BigInt Static Methods

JavaScript BigInt Static Methods

Descriptions

asIntN()Wrap a BigInt value to a signed integer between -2width-1 and 2width-1-1.
asUintN()Wrap a BigInt value to an unsigned integer between 0 and 2width-1.

JavaScript BigInt Instance Methods

JavaScript BigInt Instance Methods

Descriptions

toLocaleString()Return a string with a language-sensitive representation of this BigInt.
toString()Return a string representing the specified BigInt object.
valueOf()Return the wrapped primitive value of a BigInt object.
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!