Simplest way of getting the number of decimals in a number in JavaScript [duplicate]
问题 This question already has an answer here: Is there a reliable way in JavaScript to obtain the number of decimal places of an arbitrary number? 7 answers Is there a better way of figuring out the number of decimals on a number than in my example? var nbr = 37.435.45; var decimals = (nbr!=Math.floor(nbr))?(nbr.toString()).split('.')[1].length:0; By better I mean faster to execute and/or using a native JavaScript function, ie. something like nbr.getDecimals(). Thanks in advance! EDIT: After