Permalink
Fetching contributors…
Cannot retrieve contributors at this time
89 lines (73 sloc) 5.01 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
Number Object (JavaScript) | Microsoft Docs
01/18/2017
windows-client-threshold
devlang-javascript
language-reference
Number_JavaScript
JavaScript
TypeScript
DHTML
Number object
76e87c37-cf6c-46cc-bafa-04be1fe3d78d
23
mikejo5000
mikejo
ghogen

Number Object (JavaScript)

An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.

Syntax

  
numObj = new Number(value)  

Parameters

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

value
Required. The numeric value.

Remarks

[!INCLUDEjavascript] 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 has several number constants. For a complete list, see Number Constants.

Requirements

[!INCLUDEjsv1]

Properties

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.

Functions

The following table lists the functions of the Number object.

Function Description
Number.isFinite Function Returns a Boolean value that indicates whether a value is finite.
Number.isInteger Function Returns a Boolean value that indicates whether a value is an integer.
Number.isNaN Function Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number).
Number.isSafeInteger Returns a Boolean value that indicates whether a value can be safely represented in JavaScript.

Methods

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.

See Also

JavaScript Objects
Math Object
new Operator