소스
1 2 3 4 5 6 7 8 9
| function comma(num) { return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); }
Number.prototype.format = function () { return this.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); };
|
설명
첫번째는 함수 호출방식이고, 두번째는 NumberValue.format(); 으로 호출하면 된다.