Name
parseFloat() — NN 2 IE J1 ECMA 1
Synopsis
parseFloat(string
)
Returns a number value (either an integer or floating-point number)
of the numerals in the string passed as a parameter. The string value
must at least begin with a numeral, or the result is
NaN
. If the string starts with numbers but changes
to letters along the way, only the leading numbers are converted to
the integer. Therefore, you can use the expression:
parseFloat(navigator.appVersion)
to extract the complete version number (e.g., 4.03) that leads the otherwise long string that is returned from that property.
If the converted value does not have any nonzero values to the right of the decimal, the returned value is an integer. Floating-point values are returned only when the number calls for it.
Returned Value
Number.
Parameters
-
string
Any string that begins with one or more numerals.
Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.