parseFloat()
JavaScript Number parseFloat() method
Last Updated : 17 Mar 2025
The JavaScript number parseFloat() method parses a string argument and converts it into a floating point number. It returns NaN, if the first character of given value cannot be converted to a number.
Syntax
The parseFloat() method is represented by the following syntax:
Parameter
string - It represents the string to be parsed.
Return
A floating point number parsed from the given value.
JavaScript Number parseFloat() method example
Here, we will understand parseFloat() method through various examples.
Example 1
Let's see a simple example of parseFloat() method.
Output:
Example 2
Let's see an example to add two strings with and without using parseFloat() method.
Output:
Before invoking parseFloat(): 10.4520.55 After invoking parseFloat(): 31