 # JavaScript parseFloat: Convert String to Float Number

## JavaScript parseFloat Function

While working with numbers and decimal point numbers in javascript, it is necessary to know what you can do with them, but the most important thing is how to do it.

In this Javascript tutorial, we will discuss about the javaScript parseFloat () function, you will learn what is parseFloat in javascript and what it does. You will learn from this javascript parseFloat example. After finishing this quick guide, you will be familiar with JavaScript Parsing () syntax and where you should use it.

• JavaScript parseFloat() Function Syntax
• Example

The javascript parseFloat () function returns an floating point number by parse the string. ParseFloat () Javascript has an inbuilt function.
ParseFloat is accept the string and convert it to a floating point number. If there is not put the value in this function, this is gives return NAN.

#### JavaScript parseFloat() Function Syntax

The syntax of javascript parseFloat () is very simple. The JavaScript parseFloat () should look like this :

```parseFloat(string)
```
• Params : It accepts a parameter “string value” that contains a string that is changed to floating-point number.

To understand what parseFloat is in JavaScript, it is necessary to see an example. Take a look at this parseFloat function example – where we parse different numbers and strings :

#### Example

```<script>

// return float value
a = parseFloat("  10  ")
document.write('parseFloat("  10  ") = ' +a +"<br>");

b = parseFloat("123abc")
document.write('parseFloat("123abc") = '+b +"<br>");

// returns NaN value
c = parseFloat("abc456")
document.write('parseFloat("abc456") = ' +c +"<br>");

d = parseFloat("3.14")
document.write('parseFloat("3.14") = '+d +"<br>");

// returns only first Number
e = parseFloat("18 2 2019")
document.write('parseFloat("18 2 2019") = ' +e +"<br>");

</script>
```

#### Output

` parseFloat(" 10 ") = 10parseFloat("123abc") = 123parseFloat("abc456") = NaNparseFloat("3.14") = 3.14parseFloat("18 2 2019") = 18 `