Math.formatFloat = function (f, digit) { var m = Math.pow(10, digit); return parseInt(f * m, 10) / m; };
使用:var fee = Math.formatFloat(Number(a) + Number(b), 8).toFixed(2);
function formatThousand(num) { num = num + ""; var re = /(-?\d+)(\d{3})/; while (re.test(num)) { num = num.replace(re, "$1,$2"); } return num; }
使用:formatThousand(fee);