Convert a float number to a whole number in JavaScript - Javascript Data Type

Javascript examples for Data Type:Float

Description

Convert a float number to a whole number in JavaScript

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(){/*from   w  ww . j av  a  2  s .  c  o  m*/
console.log(12.3 ^ 0); // 12
console.log("12.3" ^ 0); // 12
console.log(1.2 + 1.3 ^ 0); // 2
console.log(1.2 + 1.3 * 2 ^ 0); // 3
console.log(-1.2 ^ 0); // -1
console.log(-1.2 + 1 ^ 0); // 0
console.log(-1.2 - 1.3 ^ 0); // -2
    }

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

Related Tutorials