首页 > 代码库 > javascript数字千分分隔符

javascript数字千分分隔符

function thousandBitSeparator(num) {
  num=num.toFixed(2);
   return num && num
   .toString()
   .replace(/(\d)(?=(\d{3})+\.)/g, function($1,$2) {
   return $2 + ",";
   });
}
console.log(thousandBitSeparator(-111111111111110.0000001));

  

javascript数字千分分隔符