JS - money 格式化,超过三位数加逗号

73 阅读1分钟
const formatMoney = num => num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
formatMoney(10000); // 10,000