JS Built-ins
NumberMAX_SAFE_INTEGERintermediate

Number.MAX_SAFE_INTEGER β€” usage in loop bounds

πŸ“– Usage Example
// 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.

Using MAX_SAFE_INTEGER as a Loop Bound

You can use Number.MAX_SAFE_INTEGER to ensure loop counters stay in the safe integer range.

πŸ’‘ Hints (1)
  • β€’ Comparing against `MAX_SAFE_INTEGER` ensures your integer arithmetic is safe.