Difference between parseFloat and parseInt - Javascript Data Type

Javascript examples for Data Type:Float

Description

Difference between parseFloat and parseInt

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//w  w  w.j  ava2s.  c  o m
var x = -0.15;
console.log('using parseFloat', parseFloat(x) < 0);
console.log('using parseInt', parseInt(x) < 0);
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials