Easy Tutorial
❮ Met Win Clearinterval Jsref Keys ❯

JavaScript Number() Function


Definition and Usage

The Number() function converts the object's value to a number.

If the object's value cannot be converted to a number, the Number() function returns NaN.

Syntax

Parameter Description
object Optional. A JavaScript object. If no argument is provided, it returns 0.

Browser Support

All major browsers support the Number() function.


Tips and Notes

Note: If the argument is a Date object, Number() returns the number of milliseconds since January 1, 1970.


Examples

Convert different objects to numbers:

The output for the above examples:

❮ Met Win Clearinterval Jsref Keys ❯