- 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.
- Only the first number in the string is returned.
- If the first character cannot be converted to a number, parseFloat() returns NaN.
Code:-
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- <h1>parseFloat()</h1>
- <h2>77.36</h2>
- <input type="button" onclick="con_float();" value="parseFloat(77.36)">
- <script>
- function con_float()
- {
- var n1 = "77.36";
- alert("Floating point : " + parseFloat(n1));
- }
- </script>
- </body>
- </html>
The parseFloat in JavaScript:- Geniusofstudent
Reviewed by Network security
on
July 02, 2019
Rating:
No comments: