The parseFloat in JavaScript:- Geniusofstudent

  • 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:-

  1. <!DOCTYPE html> 
  2. <html> 
  3.  
  4. <head> 
  5.  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  6. </head> 
  7.  
  8. <body> 
  9.  <h1>parseFloat()</h1> 
  10.  <h2>77.36</h2> 
  11.  
  12.  <input type="button" onclick="con_float();" value="parseFloat(77.36)"> 
  13.  
  14.  <script> 
  15.   function con_float() 
  16.   { 
  17.    var n1 = "77.36"; 
  18.    alert("Floating point : " + parseFloat(n1)); 
  19.   } 
  20.  </script> 
  21.  
  22. </body> 
  23.  
  24. </html>
The parseFloat in JavaScript:- Geniusofstudent The parseFloat in JavaScript:- Geniusofstudent Reviewed by Network security on July 02, 2019 Rating: 5

No comments:

Useful Information

Powered by Blogger.