toFixed var num =0.49999; num = num.toFixed(2); console.log(num); // 输出结果:0.50 Math.floor var num = 0.49999; num = Math.floor(num * 100) / 100; console.log(num); //输出结果:0.49 JavaScript 保留两位小数的三种实现方法