JavaScript 四舍五入到指定位数
const round = (n, d) => Number(`${Math.round(`${n}e${d}`)}e-${d}`);
let result1 = round(1.666, 2)
let result2 = round(1.888, 2)
console.log(result1);
console.log(result2);
本文来自博客园,作者:重庆熊猫,转载请注明原文链接:https://www.cnblogs.com/cqpanda/p/16813882.html