You can use the module operator > :
var num = 12.1542; console.log(num % 1);
However, due to the nature of the floating point numbers, you will get a number that is very slightly different. In the above example, Chrome gives me 0.15419999999999945 .
Another (slightly longer) option would be to use Math.floor , and then subtract the result from the original number:
var num = 12.1542; console.log(num - Math.floor(num));β
Again, due to the nature of the floating point numbers, you will get a number that is slightly different from what you might expect.
source share