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.
Constructor
Number()
-
Creates a new
Number
value.
When Number
is called as a constructor (with new
), it creates a Number
object, which is not a primitive. For example, typeof new Number(42) === "object"
, and new Number(42) !== 42
(although new Number(42) == 42
).
Warning: You should rarely find yourself using Number
as a constructor.