parseFloat("27.2 metres"); // 27.2
parseFloat("23,45"); // 23
parseFloat("$12.34"); // NaN
parseFloat(".21"); // 0.21
parseFloat(); // NaN
parseFloat("56,"); // 56
The parseFloat() function parses a string and returns a floating point number.
This function determines if the first character in the specified string is a number. If it is, it parses the string until it reaches the end of the number, and returns the number as a number, not as a string. If the first character cannot be converted to a number, parseFloat() returns NaN.
Login in to like
Login in to comment