Number Object (JavaScript)
An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.
numObj = new Number(value)
JavaScript creates Number objects when a variable is set to a number value, for example var num = 255.336;. It is seldom necessary to create Number objects explicitly.
The Number object has its own properties and methods, in addition to the properties and methods inherited from Object. Numbers are converted into strings under certain circumstances, for example when a number is added or concatenated with a string, as well as by means of the toString method. For more information, see Addition Operator (+) (JavaScript).
JavaScript has several number constants. For a complete list, see Number Constants (JavaScript).
Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards. Also supported in Windows Store apps. See Version Information.
The following table lists the methods of the Number object.
|
Method |
Description |
|---|---|
|
Returns a Boolean value that indicates whether an object has a property with the specified name. |
|
|
Returns a Boolean value that indicates whether an object exists in another object's prototype hierarchy. |
|
|
Returns a Boolean value that indicates whether a specified property is part of an object and whether it is enumerable. |
|
|
Returns a string that contains a number represented in exponential notation. |
|
|
Returns a string that represents a number in fixed-point notation. |
|
|
Returns an object converted to a string based on the current locale. |
|
|
Returns a string that contains a number that is represented in either exponential or fixed-point notation and that has a specified number of digits. |
|
|
Returns a string representation of an object. |
|
|
Returns the primitive value of the specified object. |