Javascript
1K 1천 1.1천 같이 숫자를 포맷하기
mark340
2023. 12. 26. 14:28
1천, 1만, 1.1만
- 숫자 표기가 길어질 때가 있다. 짧게 단위를 붙여서 표기해보자
const compactNumberFormatter = new Intl.NumberFormat('ko', {
notation: 'compact',
});
function compactNumber(number: number): string {
return compactNumberFormatter.format(number);
}