JavaScript Kit > JavaScript Reference > Here

Number Object

Last updated: June 20th, 2004

The Number object is an object wrapper for primitive numeric values. It contains some useful methods, introduced in JavaScript 1.5.


new Number(value)
Number (value)

where "value" is the numeric value of the Number object to be created, or value to be converted to a number.

Related Tutorials


Properties Description
MAX_VALUE The largest representable number in JavaScript.
MIN_VALUE The smallest representable number in JavaScript.
NaN "Not a number" value.
NEGATIVE_INFINITY Negative infinity, returned on overflow.
POSITIVE_INFINITY Infinity, returned on overflow.
prototype Prototype property, to add custom properties and methods to this object.


Methods Description
toExponential(x) Returns a number in exponential notation (string format). "x" should be a number between 0 and 20, dictating the number of digits to include in the notation after the decimal place.
toFixed(x) Formats any number for "x" number of trailing decimals. The number is rounded up, and "0"s are used after the decimal point if needed to create the desired decimal length. Example(s)
toPrecision(x) Formats any number so it is of "x" length. Also called significant digits. A decimal point and "0"s are used if needed to create the desired length.

Note: All methods above are introduced in JavaScript 1.5, and only supported in IE6+ and NS6+.



var profits=2489.8237
profits.toFixed(3) //returns 2489.824 (round up)
profits.toFixed(2) //returns 2489.82

Reference List

Right column

CopyRight (c) 2018 JavaScript Kit. NO PART may be reproduced without author's permission. Contact Info