The primary purpose of the Number object is to collect properties and methods that are used for the default numeric data type, the Number data type. The numeric constants provided by the properties of the Number object are listed in the table below.
Properties of the Number Object
Property | Description |
---|---|
MAX_VALUE |
Largest possible number, about 1.79E+308; can be positive or negative. (Value varies slightly from system to system.) |
MIN_VALUE |
Smallest possible number, about 2.22E-308; can be positive or negative. (Value varies slightly from system to system.) |
NaN |
Special nonnumeric value, "not a number." |
POSITIVE_INFINITY |
Any positive value larger than the largest positive number (Number.MAX_VALUE) is automatically converted to this value; represented as infinity. |
NEGATIVE_INFINITY |
Any value more negative than the largest negative number (-Number.MAX_VALUE) is automatically converted to this value; represented as -infinity. |
Number.NaN is a special property that is defined as not a number. Number.NaN is returned when an expression that cannot be represented as a number is used in a numeric context. For example, NaN is returned when either the string "Hello" or 0/0 (zero divided by zero) is used as a number. NaN compares as unequal to any number and to itself. To test for a NaN result, do not compare against Number.NaN; use the isNaN method of the Global object instead.
The toLocaleString method of the Number object produces a string value that represents the value of the number formatted as appropriate for the host environment's current locale. The formatting used makes large numbers easier to read by separating groups of digits to the left of the decimal point with a (locale dependent) character. For more information, see toLocaleString Method.