본문 바로가기

개발하자/자바스크립트

자바스크립트 천단위 콤마찍기 (정규식)

function addCommas(x) {

return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");

}