Number() (Function)

A Number type convertor.


ECMAScript edition - 2
JavaScript - 1.2
JScript - 1.0
Internet Explorer - 3.02
Netscape - 4.0
Property/method value type:Number primitive
JavaScript syntax:-Number()
Argument list:aValueA value to be converted to a number.

When the Number() constructor is called as a function, it will perform a type conversion.

The following values are yielded as a result of calling Number() as a function:

No value0
UndefinedReturns NaN
Boolean false0
Boolean true1
NumberNo conversion, the input value is returned unchanged.
Non numeric stringNaN
Numeric stringThe numeric value rounded down if the number of digits exceeds the numeric accuracy specified by Number.MAX_VALUE.
ObjectInternally, a conversion to one of the primitive types happens followed by a conversion from that type to a number. Some objects will return a number that is readily usable; others will return something that cannot be converted and NaN will result.

The result is a number value that is equivalent to the value of the passed in argument. If the argument is omitted the value 0 is returned.


See also:Cast operator, Constructor function, constructor property, Implicit conversion, Math.ceil(), Math.floor(), Math.round(), Number.prototype, String()


ECMA 262 edition 2 - section -

ECMA 262 edition 2 - section - 15.7.1

ECMA 262 edition 3 - section - 15.7.1

Wrox Instant JavaScript - page - 36