1var length = (number + '').replace('.', '').replace('-', '').length; // for numbers that can be floats or negatives
1var x = 23.453453453;
2x.countDecimals(); // 9
3
4var countDecimals = function (value) {
5 if(Math.floor(value) === value) return 0;
6 return value.toString().split(".")[1].length || 0;
7}