Export (0) Print
Expand All
1 out of 2 rated this helpful - Rate this topic

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)
numObj

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

value

Required. The numeric 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, Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.