Code1 [JavaScript] 숫자표기시 콤마(,) 표기시키기 [code] 숫자에 콤마넣기 //add콤마 (소수점 아래는 콤마 안찍음) function AddComma(num) { num = num.toString(); let frontNum = num.split(".")[0]; let backNum = num.split(".")[1]; const regexp = /\B(?=(\d{3})+(?!\d))/g; frontNum = frontNum.toString().replace(regexp, ','); return frontNum +"."+backNum; } 웹개발/Java & JavaScript 2020. 9. 9. 이전 1 다음