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.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access