src/intcomma.js
function numberWithCommas(n) {
  const parts = n.toString().split('.');
  parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
  return parts.join('.');
}
function numberWithCommas(n) {
  const parts = n.toString().split('.');
  parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
  return parts.join('.');
}
function numberWithCommas ( n ) { const parts = n . toString ( ) . split ( '.' ) ; parts [ 0 ] = parts [ 0 ] . replace ( / \B(?=(\d{3})+(?!\d)) / g , ',' ) ; return parts . join ( '.' ) ; }
Converts a number to include commas, if necessary.

Source: http://stackoverflow.com/a/2901298

@private
@param  {number|string} n
@return {string}
Converts a number to include commas if necessary .