Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Number values represent floating-point numbers like 37 or -9.25.
The Number constructor contains constants and methods for working with numbers. Values of other types can be converted to numbers using the Number() function.
Numbers are most commonly expressed in literal forms like 255 or 3.14159. The lexical grammar contains a more detailed reference.
A number literal like 37 in JavaScript code is a floating-point value, not an integer. There is no separate integer type in common everyday use. (JavaScript also has a BigInt type, but it's not designed to replace Number for everyday uses. 37 is still a number, not a BigInt.)
When used as a function, Number(value) converts a string or other value to the Number type. If the value can't be converted, it returns NaN.
The JavaScript Number type is a double-precision 64-bit binary format IEEE 754 value, like double in Java or C#. This means it can represent fractional values, but there are some limits to the stored number's magnitude and precision. Very briefly, an IEEE 754 double-precision number uses 64 bits to represent 3 parts:
The mantissa (also called significand) is the part of the number representing the actual value (significant digits). The exponent is the power of 2 that the mantissa should be multiplied by. Thinking about it as scientific notation:
Number=(−1)sign⋅(1+mantissa)⋅2exponent\text{Number} = ({-1})^{\text{sign}} \cdot (1 + \text{mantissa}) \cdot 2^{\text{exponent}}The mantissa is stored with 52 bits, interpreted as digits after 1.… in a binary fractional number. Therefore, the mantissa's precision is 2-52 (obtainable via Number.EPSILON), or about 15 to 17 decimal places; arithmetic above that level of precision is subject to rounding.
The largest value a number can hold is 21023 × (2 - 2-52) (with the exponent being 1023 and the mantissa being 0.1111… in base 2), which is obtainable via Number.MAX_VALUE. Values higher than that are replaced with the special number constant Infinity.
Integers can only be represented without loss of precision in the range -253 + 1 to 253 - 1, inclusive (obtainable via Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER), because the mantissa can only hold 53 bits (including the leading 1).
More details on this are described in the ECMAScript standard.
Many built-in operations that expect numbers first coerce their arguments to numbers (which is largely why Number objects behave similarly to number primitives). The operation can be summarized as follows:
There are two ways to achieve nearly the same effect in JavaScript.
Number.parseFloat() and Number.parseInt() are similar to Number() but only convert strings, and have slightly different parsing rules. For example, parseInt() doesn't recognize the decimal point, and parseFloat() doesn't recognize the 0x prefix.
Some operations expect integers, most notably those that work with array/string indices, date/time components, and number radixes. After performing the number coercion steps above, the result is truncated to an integer (by discarding the fractional part). If the number is ±Infinity, it's returned as-is. If the number is NaN or -0, it's returned as 0. The result is therefore always an integer (which is not -0) or ±Infinity.
Notably, when converted to integers, both undefined and null become 0, because undefined is converted to NaN, which also becomes 0.
JavaScript has some lower-level functions that deal with the binary encoding of integer numbers, most notably bitwise operators and TypedArray objects. Bitwise operators always convert the operands to 32-bit integers. In these cases, after converting the value to a number, the number is then normalized to the given width by first truncating the fractional part and then taking the lowest bits in the integer's two's complement encoding.
Creates Number objects. When called as a function, it returns primitive values of type Number.
The smallest interval between two representable numbers.
Number.MAX_SAFE_INTEGERThe maximum safe integer in JavaScript (253 - 1).
Number.MAX_VALUEThe largest positive representable number.
Number.MIN_SAFE_INTEGERThe minimum safe integer in JavaScript (-(253 - 1)).
Number.MIN_VALUEThe smallest positive representable number—that is, the positive number closest to zero (without actually being zero).
Number.NaNSpecial "Not a Number" value.
Number.NEGATIVE_INFINITYSpecial value representing negative infinity. Returned on overflow.
Number.POSITIVE_INFINITYSpecial value representing infinity. Returned on overflow.
Determine whether the passed value is a finite number.
Number.isInteger()Determine whether the passed value is an integer.
Number.isNaN()Determine whether the passed value is NaN.
Number.isSafeInteger()Determine whether the passed value is a safe integer (number between -(253 - 1) and 253 - 1).
Number.parseFloat()This is the same as the global parseFloat() function.
Number.parseInt()This is the same as the global parseInt() function.
These properties are defined on Number.prototype and shared by all Number instances.
Number.prototype.constructorThe constructor function that created the instance object. For Number instances, the initial value is the Number constructor.
Returns a string representing the number in exponential notation.
Number.prototype.toFixed()Returns a string representing the number in fixed-point notation.
Number.prototype.toLocaleString()Returns a string with a language sensitive representation of this number. Overrides the Object.prototype.toLocaleString() method.
Number.prototype.toPrecision()Returns a string representing the number to a specified precision in fixed-point or exponential notation.
Number.prototype.toString()Returns a string representing the specified object in the specified radix ("base"). Overrides the Object.prototype.toString() method.
Number.prototype.valueOf()Returns the primitive value of the specified object. Overrides the Object.prototype.valueOf() method.
The following example uses the Number object's properties to assign values to several numeric variables:
The following example shows the minimum and maximum integer values that can be represented as Number object.
When parsing data that has been serialized to JSON, integer values falling outside of this range can be expected to become corrupted when JSON parser coerces them to Number type.
A possible workaround is to use String instead.
Larger numbers can be represented using the BigInt type.
The following example converts the Date object to a numerical value using Number as a function:
This logs 819199440000.
| ECMAScript® 2027 Language Specification # sec-number-objects |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 10, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.