JavaScript Number Object
The JavaScript Number Object acts as a wrapper for primitive data type Number, which is used to store numeric values, both integer and floating-point values.
The Number object contains the below properties and methods.
For more details on numbers, check JavaScript Numbers.
Number Properties
Here is the list of properties available in this object.
Property | Description |
MIN_SAFE_INTEGER |
Represents the maximum safe integer in JavaScript (253 - 1). |
MAX_VALUE |
Returns the largest numeric value representable in JavaScript, approximately 1.79E+308. Values larger than MAX_VALUE are represented as Infinity . |
MIN_SAFE_INTEGER |
Represents the minimum safe integer in JavaScript (-(253 - 1)). |
MIN_VALUE |
Returns the smallest positive numeric value representable in JavaScript, approximately 5e-324. It is closest to 0, not the most negative number. Values smaller than MIN_VALUE are converted to 0. |
NEGATIVE_INFINITY |
Represents the negative infinity value. |
NaN |
Represents the "Not-A-Number" value. |
POSITIVE_INFINITY |
Represents the infinity value. |
prototype |
Allows you to add new properties and methods to a Number object. |
Number Methods
Here is the list of methods available in this object.
Method | Description |
isFinite() | Checks whether the passed value is a finite number. |
isInteger() | Checks whether the passed value is an integer. |
isNaN() | Checks whether the passed value is NaN and its type is Number. |
isSafeInteger() | Checks whether a value is a safe integer. |
toExponential() | Converts a number to exponential notation. |
toFixed() | Formats a number using fixed-point notation. |
toPrecision() | Returns a string representing the number to the specified precision. |
toString() | Converts a number to a string. |
valueOf() | Returns the primitive value of a Number object. |
Overall
JavaScript Number object acts as a wrapper for primitive data type Number, which is used to store numeric values.