JavaScript Numbers Guide
Numbers in JavaScript follow the IEEE 754 double-precision floating-point format, meaning all numbers are 64-bit floats with no separate integer type. This guide covers methods for numeric operations, formatting, and type conversion. JavaScript numbers can safely represent integers up to 2^53 - 1 (Number.MAX_SAFE_INTEGER), beyond which precision is lost. For larger integers, BigInt is the built-in solution. Understanding number behavior is critical for financial calculations, scientific computing, and any code that requires precise arithmetic. The guide walks through Number Creation & Type Checking, Formatting Numbers, Math Utilities & Constants, Floating-Point Precision Issues, BigInt for Large Integers. Use `Number()`, `parseInt()`, `parseFloat()` for conversion from strings. `parseInt(str, radix)` should always be called with a radix parameter to avoid octal interpretation of leading zeros. `isNaN()` and `isFinite()` perform type coercion before checking, while `Number.isNaN()` and `Number.isFinite()` do not, making the Number-prefixed versions safer and more predictable. `Number.isInteger()` returns true only for finite integers, excluding Infinity and NaN. The unary… `toFixed(digits)` formats with fixed decimal places and returns a string, useful for currency display. `toExponential()` produces scientific notation like `"1.23e+5"`. `toPrecision(significantDigits)` controls the total number of significant digits. `toLocaleString()` formats numbers according to the runtime locale, supporting currency, units, and compact notation: `(1234.5).toLocaleString("en-US", {style:"currency", currency:"USD"})` produces `"$1,234.50"`. The `Intl.NumberFormat` constructor provides better performance than `toLocaleString()` when formatting many numbers with…