parseFloat(string)
string | A string that represents the value you want to parse. |
parseFloat
function is a built-in JavaScript function.
parseFloat
parses its argument, a string, and returns a floating point number. If it encounters a character other than a sign (+ or -), numeral (0-9), a decimal point, or an exponent, then it returns the value up to that point and ignores that character and all succeeding characters.
If the first character cannot be converted to a number, parseFloat
returns "NaN"
.
parseFloat("3.14")The following example returns
parseFloat("314e-2")
parseFloat("0.0314E+2")
var x = "3.14"
parseFloat(x)
"NaN"
:parseFloat("FF2")
isNaN
, parseInt
Last Updated: 10/31/97 16:38:00