Example 1 — One Typed Array, Two Locales
Whole-number sales figures are formatted for the United States and for Germany.
const sales = new Int32Array([-1500, 25000, 3000000]);
console.log(sales.toLocaleString('en-US')); // -1,500,25,000,3,000,000
console.log(sales.toLocaleString('de-DE')); // -1.500,25.000,3.000.000
console.log(sales.join()); // -1500,25000,3000000 How It Works
- US style groups with commas. With
"en-US"each number gets a comma every three digits, for example3,000,000. - German style groups with dots. With
"de-DE"the group separator is a dot, so the same number is3.000.000. - The list comma never changes. The numbers are joined with a plain comma in both lines. Plain
join()shows the raw numbers.

