function commafy(num){ return num && num .toString() .replace(/(\d)(?=(\d{3})+\.)/g, function($1, $2){ return $2 + ‘,‘; }); } console.log(commafy(1200000123123.223))
let milliFormat = (input) => { return input && input.toString() .replace(/(^|\s)\d+/g, (m) => m.replace(/(?=(?!\b)(\d{3})+$)/g, ‘,‘)) } console.log(milliFormat(1200000123123.223))