Name
Number
Constructor
new Number(value) Number(value)
With the new operator, the Number( ) constructor converts its argument to a numeric value and
returns a new Number object wrapped around that value. Without
new, Number( ) is a conversion
function that converts its argument to a number and returns that
value.
Constants
These constants are properties of Number itself,
not of individual Number objects.
-
Number.MAX_VALUE The largest representable number. Approximately 1.79E + 308.
-
Number.MIN_VALUE The smallest representable number. Approximately 5E - 324.
-
Number.NaN Not-a-number value. Same as the global
NaN.-
Number.NEGATIVE_INFINITY Negative infinite value.
-
Number.POSITIVE_INFINITY Infinite value. Same as global
Infinity.
Methods
-
toExponential(digits) Returns a string representation of the number, in exponential notation, with one digit before the decimal place and
digitsdigits after the decimal place. The fractional part of the number is rounded, or padded with zeros so that it has the specified length.digitsmust be between 0 and 20, and if omitted, as many digits as necessary are used. JS 1.5; JScript 5.5; ECMA v3.-
toFixed(digits) Returns a string representation of the number that does not use exponential notation, and has exactly
digitsdigits after the decimal place.digitsmust be between 0 and 20. The number is rounded or padded with zeros if necessary. JS 1.5; JScript 5.5; ECMA v3.-
toLocaleString( ) Returns an implementation-dependent string representation of the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access