Description
The parseFloat() function is used to parse a string and return a floating point number.
This function has the form:
parseFloat(string)
Parameter | Description |
---|---|
string | (optional) The string to be parsed |
Note: If the first character cannot be converted to a number, parseFloat() returns NaN.
Examples
The following example shows the basic use of this method.
<script>
document.write(parseFloat("5"));
document.write("<br />");
document.write(parseFloat("123.45"));
document.write("<br />");
document.write(isNaN("67 89 1"));
</script>
This produces the following result:
Browser Support
Firefox | IE | Chrome | Opera | Safari |
---|---|---|---|---|