JavaScript number function | Convert the data type to number

JavaScript number function is used to convert the data type to number. It can Convert different object values (Strings, boolean, etc) to their numbers.


Parameter Values

Input variable, But its optional. If no argument is provided, it returns 0.

Return value

It returns the number (integer) format for any type of the JavaScript variable.

Example of JavaScript number function

Let’s see the example of How to convert the data type to number using a Number() function in js.


JavaScript number function

Value cannot be converted

If you pass the value non number then it will return the NaN.

Convert the data type to number

Do comment if you have any suggestions and doubts on this function.

Note: The All JS Examples codes are tested on the Safari browser (Version 12.0.2) and Chrome.
OS: macOS 10.14 Mojave
Code: HTML 5 Version

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.