JavaScript Number Basics
JavaScript has a single numeric type — Number — which represents all numeric values as 64-bit double-precision floating-point numbers following the IEEE 754 standard. This means integers and decimals share the same type, but it also introduces some surprising behaviours when precision matters.
Integer and Float Values
There is no separate integer type. Writing 42 and 42.0 produces the same value. Integers are represented exactly up to 2^53 − 1 (also available as Number.MAX_SAFE_INTEGER). Beyond that limit, arithmetic can lose precision.
NaN — Not a Number
NaN is a special numeric value that results from invalid arithmetic, such as dividing zero by zero or parsing a non-numeric string. Crucially, NaN !== NaN — it is the only value in JavaScript not equal to itself. Use Number.isNaN() (not the global isNaN) to test for it reliably.
Infinity
Infinity and -Infinity result from operations like dividing a non-zero number by zero. They propagate through arithmetic and can be tested with Number.isFinite().