HTML DOM Article Object

JavaScript Numbers

JavaScript has just a single sort of number.

Numbers can be composed with, or without, decimals:


var x = 3.14;    /A number with decimals
var y = 34;      /A number without decimals

Extra vast or additional little numbers can be composed with logical (example) notation:


var x = 123e5;   /12300000
var y = 123e-5;  /0.00123

For an instructional exercise about JavaScript numbers, read our JavaScript Number Tutorial.

Number Properties

Property Description
constructor Returns the capacity that made JavaScript's Number prototype
MAX_VALUE Returns the biggest number conceivable in JavaScript
MIN_VALUE Returns the most modest number conceivable in JavaScript
NEGATIVE_INFINITY Represents negative vastness (returned on overflow)
NaN Represents a "Not-a-Number" value
POSITIVE_INFINITY Represents vastness (returned on overflow)
prototype Allows you to add properties and techniques to an object

Number Methods

Method Description
< isFinite() Checks whether an esteem is a limited number
isInteger() Checks whether an esteem is an integer
isNaN() Checks whether an esteem is Number.NaN
isSafeInteger() Checks whether an esteem is a safe integer
toExponential(x) Converts a number into an exponential notation
toFixed(x) Formats a number with x quantities of digits after the decimal point
toPrecision(x) Formats a number to x length
toString() Converts a number to a string
valueOf() Returns the crude estimation of a number