24.149. parseFloat( ): convert a string to a numberECMAScript v124.149.1. SynopsisparseFloat(s) 24.149.1.1. Arguments
24.149.1.2. ReturnsThe parsed number, or NaN if s does not begin with a valid number. In JavaScript 1.0, parseFloat( ) returns 0 instead of NaN when s cannot be parsed as a number. 24.149.2. DescriptionparseFloat( ) parses and returns the first number that occurs in s. Parsing stops, and the value is returned, when parseFloat( ) encounters a character in s that is not a valid part of the number. If s does not begin with a number that parseFloat( ) can parse, the function returns the not-a-number value NaN. Test for this return value with the isNaN( ) function. If you want to parse only the integer portion of a number, use parseInt( ) instead of parseFloat( ). 24.149.3. See AlsoisNaN( ), parseInt( ) |