SOURCE

var fomatNum = function (num) {
  var arr = num.toString().split('.');
  var l = arr[0], r = '';
  if (arr.length == 2) {
    r = arr[1];
  }
  l = l.split('').reverse().join('');
  l = l.replace(/(\d{3})/g,function (m,m1) { return m1 + ','; });
  l = l.split('').reverse().join('');
  if (l[0] == ',') {
    l = l.slice(1);
  }
  return l + '.' + r;
}
console.log(fomatNum(24636723.14))
console 命令行工具 X clear

                    
>
console