August 1999
Intermediate to advanced
1488 pages
72h 53m
English
parseFloat(string)
The parseFloat() method is used to convert a string to a number.
Listing 6.204 shows how the parseFloat() is used. In the example, parseFloat is called with two different strings. The first string, which contains numeric characters, is converted into a number without any problem. The second string, which contains alphabetic characters, is unable to be converted into a number.
<html> <body> <script language="JavaScript"> <!–– Hide // convert the "1245.31" string to a number document.write("The string 1245.31 converted is" + parseFloat("1245.31") + "<br>"); ... |
Read now
Unlock full access