Javascript Number sigFig(precision)

Description

Javascript Number sigFig(precision)


'use strict'//from w w w .j a  va 2 s  .  c  o m

Number.prototype.sigFig = function(precision){
    if( !precision ) precision = 2;
    var d = Math.pow(10, precision);
    return ( parseInt( this.valueOf() * d) / d ).toFixed(precision);
};



PreviousNext

Related