How to Use the Number Object
This article describes Number
, a primitive wrapper object used to represent and manipulate numbers. "Number" represents floating point numbers like 45 or -3.24. Numbers are encoded as 64-bit binary, much like double in Java. There are some helpful functions in "Number" like Number ("123") would return the actual number 123. However, a "Number" ("Iamnotanumber") would return NaN (Not-a-Number) because it could not convert that into a number.
Static methods
Number.isFinite()
-
Determine whether the passed value is a finite number.
Number.isInteger()
-
Determine whether the passed value is an integer.
Number.isNaN()
-
Determine whether the passed value is
NaN
. Number.isSafeInteger()
-
Determine whether the passed value is a safe integer (number between -(253 - 1) and 253 - 1).
Number.parseFloat()
-
This is the same as the global
parseFloat()
function. Number.parseInt()
-
This is the same as the global
parseInt()
function.