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
|
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week