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));