function toThousand(num) { return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') } console.log(toThousand(1232432213.12)) console.log(toThousand(-1232432213))