I am using Number.prototype.toLocaleString()
like this
5000.70.toLocaleString('en-AU', {
style: 'currency',
currency: 'EUR',
currencyDisplay: 'symbol',
useGrouping: true
}) // "EUR 5,000.70"
Expected outcome is either "5,000.70 €"
or "€5,000.70"
Instead the output in Chrome is "EUR 5,000.70"
If you read up on the Intl.NumberFormat()
specification , the possible values of currencyDisplay
are:
symbol
" to use a localized currency symbol such as €, this is the default value, narrowSymbol
" to use a narrow format symbol ("$100" rather than "US$100"), code
" to use the ISO currency code, name
" to use a localized currency name such as " dollar
", So, it looks like it is a matter of setting currencyDisplay
to narrowSymbol
to achieve what you want:
const x = 5000.70.toLocaleString('en-AU', { style: 'currency', currency: 'EUR', currencyDisplay: 'narrowSymbol', useGrouping: true }); console.log(x); // €5,000.70
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.