Programing/Javascript, JQuery
[JavaScript] 숫자 세자리마다 콤마 찍기
개발하는 주린이
2021. 3. 1. 01:33
728x90
반응형
[JavaScript] 숫자 세자리마다 콤마 찍기
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
출처
How to print a number with commas as thousands separators in JavaScript
I am trying to print an integer in JavaScript with commas as thousands separators. For example, I want to show the number 1234567 as "1,234,567". How would I go about doing this? Here is how I am...
stackoverflow.com
728x90
반응형