숫자 천 단위 콤마(,) 찍기
toLocaleString()
- 날짜나 숫자를 문화권에 맞는 표기법의 문자열로 반환
- number / date / array 에서 활용
number | date | array |
3자리마다 콤마(,) | 사용자의 문화권에 맞는 시간 표기법으로 년,월, 일, 시간 반환 |
array 내용을 문자열로 반환 |
const date = new Data();
date.toLocalString();
// "2024. 03. 12. 오후 15:45:45"
const price = 20000;
price.toLocalString();
// 20,000
const array = [1, 'a', 234, date];
array.toLocalString();
// "1,a,234,2024. 03. 12. 오후 15:45:45"
참고