Javascript examples for Data Type:decimal
Find value before and after decimal point
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//from w ww .ja v a2 s . co m function getNatural(num) { return parseFloat(num.toString().split(".")[0]); } function getDecimal(num) { return parseFloat(num.toString().split(".")[1]); } var a = 12345.67; console.log(getNatural(a)); ///before dot console.log(getDecimal(a)); ///after dot }); </script> </head> <body> </body> </html>