格式化数字串隔3个就断
作者:互联网
整数缝三
function fnInttrunt(number) { let intPart = Number(number)|0; //获取整数部分 return intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') }
小数逢三
function fnfloattrunt(number) { let intPart = Number(number); return intPart.toString().replace(/\d(?=(\d{3})+\.)/g,'$&,'); }
标签:function,格式化,number,Number,return,toString,数字串,intPart 来源: https://www.cnblogs.com/xiaolanschool/p/11148869.html