Number API

Checking number types, converting, and formatting numerical values.

Number(x) tries to cast x to a number. Number provides methods like Number.isFinite and Number.isInteger to validate numerical inputs. Conversion methods such as parseFloat and parseInt transform strings into numbers, while the Number constructor converts various types. Formatting methods represent numbers in exponential or fixed-point notation, ensuring accurate numerical presentation across locales. Constants like MAX_VALUE and MIN_VALUE define numerical limits, and MAX_SAFE_INTEGER and MIN_SAFE_INTEGER are used for safe integer operations. Special values such as POSITIVE_INFINITY, NEGATIVE_INFINITY, and NaN handle overflow and invalid operations.

23 Total 14 Methods 9 Properties 17 Statics
  Show all

Number(…)

Coerces the argument to a number.Number([value])

new Number(…)

Creates a Number object.Number.new Number([value])

Number.EPSILON

The smallest difference between 1 and the next larger representable number, approximately 2.22 × 10^-16.Number.EPSILON

Number.MAX_SAFE_INTEGER

Largest integer n where n and n + 1 are both exactly representable as a Number (2^53 - 1).Number.MAX_SAFE_INTEGER

Number.MAX_VALUE

Largest positive representable number (~1.79E+308).Number.MAX_VALUE

Number.MIN_SAFE_INTEGER

Smallest integer n where n and n - 1 are both exactly representable as a Number (-(2^53 - 1)).Number.MIN_SAFE_INTEGER

Number.MIN_VALUE

Smallest positive representable number (~5E-324).Number.MIN_VALUE

Number.NEGATIVE_INFINITY

Value representing negative infinity.Number.NEGATIVE_INFINITY

Number.NaN

Not-A-Number value.Number.NaN

Number.POSITIVE_INFINITY

Value representing positive infinity.Number.POSITIVE_INFINITY

Number.isFinite(…)

Determines whether the passed value is a finite number.Number.isFinite(value)

Number.isInteger(…)

Determines whether the passed value is an integer.Number.isInteger([value])

Number.isNaN(…)

Determines whether the passed value is NaN.Number.isNaN(value)

Number.isSafeInteger(…)

An integer is a "safe integer" if the value is NOT the value for any other integer.Number.isSafeInteger(value)

Number.parseFloat(…)

Parses a string argument and returns a floating point number.Number.parseFloat([value])

Number.parseInt(…)

Parses a string argument and returns an integer.Number.parseInt(value, [radix])

Number.prototype

The prototype of the Number constructor.Number.prototype

toExponential(…)

Returns a string representing the number in exponential notation.n.toExponential([fractionDigits])

toFixed()

Returns a string representing the number in fixed-point notation.n.toFixed()

toLocaleString(…)

Returns a string with a language-sensitive representation of this number.n.toLocaleString([reserved1, [reserved2]])

toPrecision()

Returns a string representing the number to a specified precision.n.toPrecision()

toString()

Returns a string representing the specified Number object.n.toString()

valueOf()

Returns the primitive value of the specified Number object.n.valueOf()

Number.isInteger(…)

staticmethod

Determines whether the passed value is an integer. Number.isInteger([value])

Beginner Examples

The number literal 1 is an integer.Number.isInteger(1)true

The number literal 1.5 is NOT an integer.Number.isInteger(1.5)false

The string "a" is NOT an integer.Number.isInteger("a")false

The boolean false is NOT an integer.Number.isInteger(false)false

You seem to be offline. App may not work.