Building Your Learning Module...
Getting things ready for you!
Find videos you like?
Save to resource drawer for future reference!
BigInt is a new number type for working with arbitrarily large integers! Regular numbers in JavaScript are limited to Âą2^53, but BigInt lets you work with numbers as large as your memory allows. Perfect for cryptography, timestamps, and huge calculations!
9007199254740991(Number.MAX_SAFE_INTEGER). Above that, precision is lost. BigInt solves this!123nBigInt(123)BigInt handles numbers beyond JavaScript's safe integer limit
Practical scenarios for BigInt
Cannot perform operations between BigInt and Number directly
10n + 5 // â TypeError!
10n + 5n // â
Works!Math.sqrt(),Math.pow() don't work with BigInt
10n / 3n = 3n (not 3.333...)
Need to convert to string for JSON: bigInt.toString()
Work with integers of any size
123n creates BigInt literal
Must convert between BigInt and Number
Crypto, timestamps, large IDs, precise calculations