.log(change(12345.67))

function change(num) {
var str = num.toString()
var reg = str.indexOf(".") > -1 ? /(\d)(?=(\d{3})+\.)/g : /(\d)(?=(?:\d{3})+$)/g
return str.replace(reg, "$1,")
}

更多需求可参考这个​​网站​