How to Use the Number Object
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.