Class Number
A Number object represents any numerical value, whether it is an integer or floating-point number. Generally, you do not need to worry about a Number object because a numerical value automatically becomes a Number object instance when you use a numerical value or assign it to a variable.
| Constant | Description |
|---|---|
| EPSILON: Number | EPSILON is the Number value for the magnitude of the difference between 1 and the smallest value greater than 1 that is representable as a Number value, which is approximately 2.2204460492503130808472633361816 × 10-16. |
| MAX_SAFE_INTEGER: Number | The maximum safe integer in JavaScript. |
| MAX_VALUE: Number | The largest representable Number. |
| MIN_SAFE_INTEGER: Number | The minimum safe integer in JavaScript. |
| MIN_VALUE: Number | The smallest representable Number. |
| NEGATIVE_INFINITY: Number | Negative infinite value; returned on overflow; |
| NaN: Number | Not a Number. |
| POSITIVE_INFINITY: Number | Negative infinite value; returned on overflow; |
| Constructor | Description |
|---|---|
| Number() | Constructs a Number with value 0 |
| Number(Number) | Constructs a new Number using the specified Number. |
| Number(String) | Constructs a Number using the specified value. |
| Method | Description |
|---|---|
| static isFinite(Object) | Determines whether the passed value is a finite number. |
| static isInteger(Object) | Determines whether the passed value is an integer number. |
| static isNaN(Object) | Determines whether the passed value is NaN. |
| static isSafeInteger(Object) | Determines whether the passed value is a safe integer number. |
| static parseFloat(String) | Parses a String into an float Number. |
| static parseInt(String) | Parses a String into an integer Number. |
| static parseInt(String, Number) | Parses a String into an integer Number using the specified radix. |
| toExponential() | Converts this Number to a String using exponential notation. |
| toExponential(Number) | Converts this Number to a String using exponential notation with the specified number of digits after the decimal place. |
| toFixed() | Converts a Number to a String that contains a no fractional part. |
| toFixed(Number) | Converts a Number to a String that contains a specified number of digits after the decimal place. |
| toLocaleString() | Converts this Number to a String using local number formatting conventions. |
| toPrecision(Number) | Converts a Number to a String using the specified number of significant digits. |
| toString() | A String representation of this Number. |
| toString(Number) | Converts the number into a string using the specified radix (base). |
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
- EPSILON: Number
EPSILON is the Number value for the magnitude of the difference between 1 and the smallest value greater than 1 that is representable as a Number value, which is approximately 2.2204460492503130808472633361816 × 10-16.
API Version:
Available from version 22.7.
- MAX_SAFE_INTEGER: Number
The maximum safe integer in JavaScript.
API Version:
Available from version 21.2.
- MAX_VALUE: Number
The largest representable Number.
- MIN_SAFE_INTEGER: Number
The minimum safe integer in JavaScript.
API Version:
Available from version 21.2.
- MIN_VALUE: Number
The smallest representable Number.
- NEGATIVE_INFINITY: Number
Negative infinite value; returned on overflow;
- NaN: Number
Not a Number.
- POSITIVE_INFINITY: Number
Negative infinite value; returned on overflow;
- Number()
Constructs a Number with value 0
- Number(num: Number)
Constructs a new Number using the specified Number.
Parameters:
- num - the Number to use.
- Number(value: String)
Constructs a Number using the specified value.
Parameters:
- value - the value to use when creating the Number.
- static isFinite(value: Object): Boolean
Determines whether the passed value is a finite number.
Parameters:
- value - The value to check.
Returns:
trueif the passed value is a finite number, elsefalse.
API Version:
Available from version 21.2.
- static isInteger(value: Object): Boolean
Determines whether the passed value is an integer number.
Parameters:
- value - The value to check.
Returns:
trueif the passed value is a finite integer number, elsefalse.
API Version:
Available from version 21.2.
- static isNaN(value: Object): Boolean
Determines whether the passed value is
NaN. Unlike the global function, the passed parameter is not converted to number before doing the check.Parameters:
- value - The value to check.
Returns:
trueif the passed value is theNaNnumber value, elsefalse.
API Version:
Available from version 21.2.
- static isSafeInteger(value: Object): Boolean
Determines whether the passed value is a safe integer number.
Parameters:
- value - The value to check.
Returns:
trueif the passed value is a safe integer number, elsefalse.
API Version:
Available from version 21.2.
- static parseFloat(s: String): Number
Parses a String into an float Number.
Parameters:
- s - the String to parse.
Returns:
- Returns the float as a Number.
API Version:
Available from version 21.2.
- static parseInt(s: String): Number
Parses a String into an integer Number. This function is a short form for the call to parseInt(String, Number) with automatic determination of the radix. If the string starts with "0x" or "0X" then the radix is 16. In all other cases the radix is 10.
Parameters:
- s - the String to parse.
Returns:
- Returns the integer as a Number.
API Version:
Available from version 21.2.
- static parseInt(s: String, radix: Number): Number
Parses a String into an integer Number using the specified radix.
Parameters:
- s - the String to parse.
- radix - the radix to use.
Returns:
- Returns the integer as a Number.
API Version:
Available from version 21.2.
- toExponential(): String
Converts this Number to a String using exponential notation.
Returns:
- a String using exponential notation.
- toExponential(digits: Number): String
Converts this Number to a String using exponential notation with the specified number of digits after the decimal place.
Parameters:
- digits - the number of digits after the decimal place.
Returns:
- a String using exponential notation with the specified number of digits after the decimal place.
- toFixed(): String
Converts a Number to a String that contains a no fractional part.
Returns:
- a String representation of the number
- toFixed(digits: Number): String
Converts a Number to a String that contains a specified number of digits after the decimal place.
Parameters:
- digits - the number of digits after the decimal place.
Returns:
- a String that contains a specified number of digits after the decimal place.
- toLocaleString(): String
Converts this Number to a String using local number formatting conventions.
The current implementation actually only returns the same as toString().
Returns:
- a String using local number formatting conventions.
- toPrecision(precision: Number): String
Converts a Number to a String using the specified number of significant digits. Uses exponential or fixed point notation depending on the size of the number and the number of significant digits specified.
Parameters:
- precision - the precision to use when converting the Number to a String.
Returns:
- a String using the specified number of significant digits.
- toString(): String
A String representation of this Number.
Returns:
- a String representation of this Number.
- toString(radix: Number): String
Converts the number into a string using the specified radix (base).
Parameters:
- radix - the radix to use.
Returns:
- a String representation of this Number.