Javascript Number floor(scale)

Description

Javascript Number floor(scale)


Number.prototype.floor = function (scale) {
    scale = Number(scale);//from w  w  w  .java 2 s .c o  m
    if (isNaN(scale) || scale !== Number(scale.toFixed(0))) {
        return ;
    }
    var ratio = Math.pow(10,scale);
    return Math.floor(this * ratio) / ratio;
};



PreviousNext

Related