Javascript Number decimalPart()

Description

Javascript Number decimalPart()

/**//from  w ww  . j a  v a  2 s  .c o m
 * Actually you can simply use
 *      decimal%1
 * @returns {*}
 */
Number.prototype.decimalPart = function () {
    var value = parseInt(this.toString().split('.')[1], 10)
    return value ? parseFloat('0.' + value) : 0
}



PreviousNext

Related