number.js
function round(val) {
    var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;

    if (!isNumber(val) || isNumericalNaN(val)) {
        throw new TypeError('Value should be numeric');
    }

    if (precision === !1 || precision < 1) {
        return Math.round(val);
    }

    var exp = Math.pow(10, Math.round(precision));
    return Math.round(val * exp) / exp;
}
function round(val) {
    var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;

    if (!isNumber(val) || isNumericalNaN(val)) {
        throw new TypeError('Value should be numeric');
    }

    if (precision === !1 || precision < 1) {
        return Math.round(val);
    }

    var exp = Math.pow(10, Math.round(precision));
    return Math.round(val * exp) / exp;
}
function round ( val ) { var precision = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : 0 ; if ( ! isNumber ( val ) || isNumericalNaN ( val ) ) { throw new TypeError ( 'Value should be numeric' ) ; } if ( precision === ! 1 || precision < 1 ) { return Math . round ( val ) ; } var exp = Math . pow ( 10 , Math . round ( precision ) ) ; return Math . round ( val * exp ) / exp ; }
Round a decimal value
Round a decimal value