js 数字千分位格式化

function format (num) {

    return (num.toFixed(2) + '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');

}

你可能感兴趣的:(前端)