JavaScript Number parseFloat() methodThe JavaScript number parseFloat() method parses a string argument and converts it into a floating point number. It returns NaN, if the first character of given value cannot be converted to a number. SyntaxThe parseFloat() method is represented by the following syntax: Parameterstring - It represents the string to be parsed. ReturnA floating point number parsed from the given value. JavaScript Number parseFloat() method exampleHere, we will understand parseFloat() method through various examples. Example 1Let's see a simple example of parseFloat() method. Test it NowOutput: 50 50.25 NaN 50 50.25 Example 2Let's see an example to add two strings with and without using parseFloat() method. Test it NowOutput: Before invoking parseFloat(): 10.4520.55 After invoking parseFloat(): 31 Next TopicJavaScript Number |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India