JavasScript bigInt
Jump to turn (8)
- User
JavasScript bigInt
- Assistant
BigInt is a new JavaScript data type introduced in ECMAScript 2020. It is used to represent integers with arbitrary precision. BigInt values can represent integers beyond the limits of the Number data type, which can only represent integers up to 2⁵³-1 or -2⁵³-1.
To create a BigInt value, you can use the BigInt() constructor, or append the letter "n" to the end of an integer literal:
codeconst a = BigInt(123456789); const b = 987654321n;BigInt values can be used in arithmetic operations, comparisons, and other common mathematical operations. They can also be converted to other numeric types using the Number() or parseInt() functions.