bigint operator js code example
Example 1: javascript bigint
// There are two ways to create BigInt:
//1. add a suffix n to any number in JavaScript
const big = 1000000n; // 1000000n
//2. call the constructor BigInt(val) and pass in a numerical value
const bigN = BigInt(123) // 123n
//strings also work
const bigS = BigInt("234") // 234n
const bigHex = BigInt("0xffffffffffffffff") // 18446744073709551615n
const bigBin = BigInt("0b111") // 7n
Example 2: javascript bigint
const theBiggestInt = 9007199254740991n
const alsoHuge = BigInt(9007199254740991) // 9007199254740991n
const hugeString = BigInt("9007199254740991") // 9007199254740991n
const hugeHex = BigInt("0x1fffffffffffff") // 9007199254740991n
const hugeBin = BigInt("0b11111111111111111111111111111111111111111111111111111") // 9007199254740991n