JavaScript Reference/Javascript Methods/parseInt

Материал из Web эксперт
Перейти к: навигация, поиск

"parseInt()" Example

   <source lang="javascript">
   

<html> <body> <button onclick="alert(parseInt("12.34"));">Number</button> <button onclick="alert(parseInt("Hello"));">NaN</button> </body> </html>


     </source>
   
  


"parseInt()" Syntax, Parameters and Note

   <source lang="javascript">

Note: Converts the string to an integer. Returns an integer if value supplied is numeric or NaN if value supplied is not numeric.

Syntax:

parseInt(param1) Parameters:

   param1   Required; the string to be evaluated.
   
     
     </source>