Skip to content

Instantly share code, notes, and snippets.

@ibayazit
Created September 4, 2021 15:43
Show Gist options
  • Select an option

  • Save ibayazit/33f0bae097998bf834e7f6185dedfe2d to your computer and use it in GitHub Desktop.

Select an option

Save ibayazit/33f0bae097998bf834e7f6185dedfe2d to your computer and use it in GitHub Desktop.
JS Currency format
const number = 123456.789;
console.log(new Intl.NumberFormat('tr-TR', { style: 'currency', currency: 'TRY' }).format(number));
// expected output: "₺123.456,79"
// the Japanese yen doesn't use a minor unit
console.log(new Intl.NumberFormat('ja-JP', { style: 'currency', currency: 'JPY' }).format(number));
// expected output: "¥123,457"
// limit to three significant digits
console.log(new Intl.NumberFormat('en-IN', { maximumSignificantDigits: 3 }).format(number));
// expected output: "1,23,000"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment