Mrs. Tini writes price labels with Intl.NumberFormat: rupiah, percent, per kilo, or a compact "1.2M", and formatToParts shows every character the browser…
Why it matters
Prices, percentages, weights, stats: numbers written for people are in every UI. Building them yourself ('Rp ' + n) forgets the group separator, gets decimals wrong and breaks in another currency or language.
The key idea
One number, the right label for every language, through options
Common mistakes
A hand-built Rp label is wrong in other currencies'Rp ' + n forgets the group separator, gets the cents wrong and does not work for other currencies. Use style: 'currency' with the currency code.
Formatting numbers in a table is very slow Building an Intl.NumberFormat is expensive. Build it once outside the loop and reuse .format() for every number.
A percent comes out odd, like 1,500%style: percent multiplies by 100: format(0.15) gives 15%, format(15) gives 1,500%. Give it a fraction from 0 to 1.
Try it in this playground
Switch the locale: id-ID, en-US, de-DE Dots and commas trade places; the currency symbol moves.
Turn on notation: compact 1234567890 becomes 1,2 M in id-ID, 1.2B in en-US.
Write 15% with style: percent Give it 0.15, not 15: percent multiplies by 100.
Run the 5,000-label speed test A new formatter for each label is far slower than one formatter reused.