GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — JavaScript Number parseFloat() Method - GeeksforGeeks JavaScript Number parseFloat() MethodLast Updated : 11 Jul, 2025 JavaScript parseFloat() Method is used to accept the string and convert it into a floating-point number. If the string does not contain a numeral value or If the first character of the string is not a Number then it returns NaN i.e, not a number. It actually returns a floating-point number parsed up to that point where it encounters a character that is not a Number. Syntax: parseFloat(Value) Parameters: This method accepts a single parameter.
Return value: It returns a floating-point Number and if the first character of a string cannot be converted to a number then the function returns NaN i.e, not a number. Below is an example of the parseFloat() method: Example 1:
Output: Using parseFloat("3.14") = 3.14
Example 2:
Output: The parseFloat() function ignores leading and trailing spaces and returns the floating point Number of the string. parseFloat(" 100 ") = 100
parseFloat("2018@geeksforgeeks") = 2018
parseFloat("geeksforgeeks@2018") = NaN
parseFloat("3.14") = 3.14
parseFloat("22 7 2018") = 22
Example 3: Using the isNaN() function to test whether the converted values are a valid numbers or not.
Output: x is a number
y is not a number
Using parseInt("3.14") = 3
Using parseFloat("3.14") = 3.14
Supported Browsers:
We have a complete list of JavaScript Number constructor, properties, and methods list, to know more about the numbers please go through that article. Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |