less than 1 minute read

정식으로  지원되는게 있다. 언어셋 지원도 된다. new Intl.NumberFormat().format(x)


<code class=" language-js" style="word-wrap: normal; margin: 0px; border: 0px; font-weight: inherit; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; color: rgb(59, 60, 64); text-shadow: none; direction: ltr; white-space: pre; word-spacing: normal; word-break: normal; line-height: 1.5; tab-size: 4; hyphens: none; position: relative;">var number = 3500;

console.log(new Intl.NumberFormat().format(number));
// → '3,500' if in US English locale - - - - - -

console.log(number.toLocaleString());

<code class=" language-js" style="word-wrap: normal; margin: 0px; border: 0px; font-weight: inherit; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; color: rgb(59, 60, 64); text-shadow: none; direction: ltr; white-space: pre; word-spacing: normal; word-break: normal; line-height: 1.5; tab-size: 4; hyphens: none; position: relative;">var number = 3500;

console.log(number.toLocaleString()); // Displays "3,500" if in U.S. English locale


🔗original-link

Updated: