MAX_SAFE_INTEGERintermediate// Largest safely representable integer
Number.MAX_SAFE_INTEGER // β 9007199254740991
Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2 // β true (unsafe!)Use Number.MAX_SAFE_INTEGER as the upper bound when working with integers to avoid silent precision loss.
Adding 1 to Number.MAX_SAFE_INTEGER produces an incorrect result due to precision loss.
Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2 // β true!