123456789 "123,456,789" 9007199254740991 const num = 9007199254740 console.log(num) let str = String(num) let len = Math.ceil(str.length / 3 - 1) let arr = str.split("") for (let i = 1; i <= len; i++) { arr.splice(str.length - 3 * i, 0, ",") } let newStr = arr.join("") console.log(newStr)