Numbers & BigInt in JavaScript
JavaScript has one number type: 64-bit IEEE 754 double — integers exact only to 2^53 - 1 (Number.MAX_SAFE_INTEGER), with 0.1 + 0.2 famously equaling 0.30000000000000004. Special values Infinity, -Infinity, and NaN (the only value not equal to itself) cover overflow, division edge cases, and failed math.
BigInt (123n suffix or BigInt()) holds arbitrary-precision integers for IDs, timestamps, and crypto — but never mixes with Number in arithmetic (1n + 1 throws; convert explicitly). Money code uses integer cents or decimal libraries, never raw floats.
One float type
Every number is a double — integers, decimals, all of it. Safe integers end at 2^53 - 1.
0.1 + 0.2 !== 0.3
Binary fractions can't represent most decimals exactly — compare with epsilon (Math.abs(a - b) < 1e-10), never ==.
NaN means failed math
0/0, parse failures, and bad operations yield NaN — detected only via Number.isNaN(), since NaN !== NaN.
BigInt for huge integers
123n suffix or BigInt("...") for exact big integers — but 1n + 1 throws TypeError; convert deliberately.
console.log(0.1 + 0.2 === 0.3);console.log(Number.isSafeInteger(2 ** 53));console.log(10n + 20n);Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in JavaScript yourself — building beats watching.