In JavaScript, bigint literals are not available when targeting versions lower than ES2020. The introduction of the bigint type in ES2020 allows for the representation of larger integers than the previous Number type, which is limited to 53 bits of precision for integers.
Before ES2020, you can still work with big integers by using the BigInt constructor function. This function takes a string or number as an argument and returns a BigInt object with the corresponding value. Here are a few examples to illustrate this:
// BigInt constructor function
const bigint = BigInt("123456789012345678901234567890");
console.log(bigint); // Output: 123456789012345678901234567890n (n indicates a BigInt)
// You can perform arithmetic operations using BigInts
const sum = bigint + BigInt(9876543210);
console.log(sum); // Output: 123456789012345678901244444100n
// You can also convert a regular number to a BigInt
const regularNumber = 1234567890;
const bigintFromRegularNumber = BigInt(regularNumber);
console.log(bigintFromRegularNumber); // Output: 1234567890n
Note that when using BigInts, you must append the letter ‘n’ to indicate that the value is a BigInt. This is necessary because JavaScript automatically treats numbers without the ‘n’ as regular Number objects.
Read more interesting post
- Unable to load spec files quite likely because they rely on `browser` object that is not fully initialised.
- Could not create blobcontainerclient for schedulemonitor.
- Index.android.bundle decompile
- Build constraints exclude all go files
- Before running a saga, you must mount the saga middleware on the store using applymiddleware