var rounded = Math.round( number * 10 ) / 10;   // round to one digit
var rounded = Math.round( number * 100 ) / 100;   // round to two digit
function round(value, precision) {
    var multiplier = Math.pow(10, precision || 0);
    return Math.round(value * multiplier) / multiplier;
}

var fixed = rounded.toFixed(1);  // round to one digit
var fixed = rounded.toFixed(2); // round to two digit

 

 

相关文章:

  • 2022-03-08
  • 2021-05-17
  • 2022-12-23
  • 2021-04-19
  • 2022-02-04
猜你喜欢
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2021-08-19
  • 2021-10-30
相关资源
相似解决方案