var a = 123456789.01;
var retA = a.toFixed(2).replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
console.log(retA );
例如:123456789.01 转换 123,456,789.01
$1、$2、...、$99:与 regexp 中的第 1 到第 99 个子表达式相匹配的文本。
$&:与 regexp 相匹配的子串。
$`:位于匹配子串左侧的文本。
$':位于匹配子串右侧的文本。
$$:直接量符号。