对数字展示成每3位加隔字符

1 var getThousandNum = function(val){
2     var re = /(?=(?!(\b))(\d{3})+$)/g;
3     return val.indexOf(".")>=0 ? val.split(".")[0].replace(re, ",") + "." +val.split(".")[1] : val.replace(re, ",");
4 }

 

posted @ 2020-12-09 10:46  傅丹辰cds  阅读(77)  评论(0编辑  收藏  举报