JavaScript · Senior · Question 31 of 75
Why does 9007199254740993 === 9007199254740992 return true?
- ✓Correct answer: Numbers above
MAX_SAFE_INTEGERcan't be represented exactly - 2It's a V8 engine bug that shows up only in Chrome
- 3The last digit of a long numeric literal is dropped
Explanation
A double has a 53-bit mantissa, so not all integers beyond 2^53 are representable. Large IDs from APIs (e.g. 64-bit ones) come in JSON as strings or are handled via BigInt, otherwise they're silently corrupted. Check with Number.isSafeInteger.