Skip to main content
Version: 2.2.0

Number() constructor

The Number() constructor creates a Number object. When called instead as a function, it performs type conversion to a primitive number, which is usually more useful.

Syntax

new Number(value)
Number(value)

Note: Number() can be called with or without new, but with different effects. See Return value.

Parameters

  • value
    • : The numeric value of the object being created.

Return value

When Number is called as a constructor (with new), it creates a Number object, which is not a primitive.

When Number is called as a function, it coerces the parameter to a number primitive. BigInts are converted to numbers. If the value can't be converted, it returns NaN.

Warning: You should rarely find yourself using Number as a constructor.