Name
Number — support for numbers
Inherits from
Object → Number
Constructor
newNumber(value)Number(value)
Arguments
valueThe numeric value of the Number object being created or a value to be converted to a number.
Returns
When Number() is used
with the new operator as a
constructor, it returns a newly constructed Number object. When
Number() is invoked as a
function without the new
operator, it converts its argument to a primitive numeric value
and returns that value (or NaN
if the conversion failed).
Constants
Number.MAX_VALUEThe largest representable number.
Number.MIN_VALUEThe smallest representable number.
Number.NaNNot-a-number value.
Number.NEGATIVE_INFINITYNegative infinite value; returned on overflow.
Number.POSITIVE_INFINITYInfinite value; returned on overflow.
Methods
toString()Converts a number to a string using a specified radix (base).
toLocaleString()Converts a number to a string using local number-formatting conventions.
toFixed()Converts a number to a string that contains a specified number of digits after the decimal place.
toExponential()Converts a number to a string using exponential notation with the specified number of digits after the decimal place.
toPrecision()Converts a number to a string using the specified number of significant digits. Uses exponential or fixed-point notation depending on the size of the number and the number of significant digits specified.
valueOf()Returns the primitive numeric value of a Number object.
Description
Numbers are a basic, primitive datatype ...
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