금액에 천단위 콤마붙이기(javascript)
Amount of paste comma(javascript)
숫자형(Number)
Number.prototype.format = function(){if(this==0) return 0;
var reg = /(^[+-]?\d+)(\d{3})/; var n = (this + '');
while (reg.test(n)) n = n.replace(reg, '$1' + ',' + '$2');
return n;
}; // 문자열 타입에서 쓸 수 있도록 format() 함수 추가
문자형(String)
String.prototype.format = function(){var num = parseFloat(this);
if( isNaN(num) ) return "0";
return num.format();
};
exec)
var aa = 987654321
,aa = aa.format();
console.log(aa);
result)
==> 987,654,321
Excellent way of telling, and nice paragraph to take facts concerning my presentation topic, which i am
답글삭제going to deliver in college.
Here is my homepage; 3ds emulator
In fact when someone doesn't be aware of after that its up to
답글삭제other users that they will assist, so here it occurs.
Have a look at my blog post: real racing 3 cheater; mskr.net,