MSDN Library

Number Object (JavaScript)

An object representation of the number data type and placeholder for numeric constants.

numObj = new Number(value)

numobj

Required. The variable name to which the Number object is assigned.

value

Required. The numeric value of the Number object being created.

JavaScript creates Number objects as required from numerical values. It is rarely necessary to create Number objects explicitly.

The primary purposes for the Number object are to collect its properties into one object, and to allow numbers to be converted into strings via the toString method.

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information.

The following table lists the constants of the Number object.

Constant

Description

Number.MAX_VALUE

The largest number that can be represented in JavaScript.

Number.MIN_VALUE

The closest number to zero that can be represented in JavaScript.

Number.NaN

A special value that indicates that an arithmetic expression returned a value that is not a number.

Number.NEGATIVE_INFINITY

A value that is more negative than the largest negative number that can be represented in JavaScript.

Number.POSITIVE_INFINITY

A value that is larger than the largest number that can be represented in JavaScript.

The following table lists the properties of the Number object.

Property

Description

constructor Property

Specifies the function that creates an object.

prototype Property

Returns a reference to the prototype for a class of objects.

The following table lists the methods of the Number object.

Method

Description

hasOwnProperty Method

Returns a Boolean value that indicates whether an object has a property with the specified name.

isPrototypeOf Method

Returns a Boolean value that indicates whether an object exists in another object's prototype hierarchy.

propertyIsEnumerable Method

Returns a Boolean value that indicates whether a specified property is part of an object and whether it is enumerable.

toExponential method

Returns a string that contains a number represented in exponential notation.

toFixed method

Returns a string that represents a number in fixed-point notation.

toLocaleString Method

Returns an object converted to a string based on the current locale.

toPrecision method

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.

toString Method

Returns a string representation of an object.

valueOf Method

Returns the primitive value of the specified object.

Community Additions

Show:
© 2016 Microsoft