JavaScript Number Object

Last Updated Jul 29, 2015, 07:00:14 PM





JavaScript Number Object

The Number object represents numerical date, either integers or floating-point numbers.

The Number JavaScript object is a wrapper object allowing you to work with numerical values. A Number object is created using the Number() constructor.


Declaration
Description

If the argument cannot be converted into a number, it returns NaN.

In a non-constructor context (i.e., without the new operator), Number can be used to perform a type conversion.

Number Properties

Here is a list of each property, description and live example for each property.

Property Description Example
MAX_VALUE Get the largest number possible in JavaScript Try It Now
MIN_VALUE Get the smallest number possible in JavaScript Try It Now
NEGATIVE_INFINITY Represents the negative Infinity value. Try It Now
POSITIVE_INFINITY Represents the positive Infinity value.. Try It Now

Number Methods

Method Description Example
toString() toString method is used to convert number to a string Try It Now
valueOf() valueOf()method returns the primitive numeric value represented by the object. Try It Now
toExponential() toExponential()method returns a string representing the Number object in exponential notation. Try It Now
toFixed() toFixed() method is responsible to format a number with a specific number of digits to the right side of the decimal. . Try It Now
toLocaleString() The toLocaleString() method returns a string with a language sensitive representation of this number . Try It Now
toPrecision() toPrecision() method is responsible for returning a string representing the number object to the specified precision. Try It Now

Here is the list of all important JavaScript Native Objects −



JavaScript Boolean Object

JavaScript String Object

JavaScript Number Object


Sources and Credits

The source of the content has been referred and updated with Mozilla Developer Network and W3C Organization

Last Updated Jul 29, 2015, 07:00:14 PM





Browser compatibility

Feature
Basic support Yes Yes Yes Yes Yes Yes Yes