Methods
asCurrency(number, localeopt, currencyopt, nullable, currencyDisplayopt, nullable) → {String}
Renders a number as a currency value, using native Intl.NumberFormat functionality.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
number |
Number | the number to use as a currency amount |
||
locale |
String | Array.<String> |
<optional> |
'en-US' | locale to use, use array to define fallback; always falls back to en-US if nothing else works |
currency |
String |
<optional> <nullable> |
'USD' | a ISO4217 currency code, such as EUR for Euro |
currencyDisplay |
String |
<optional> <nullable> |
'symbol' | one of "symbol", "narrowSymbol", "code" or "name", defining, how the currency should be displayed in the result |
- Source:
- See:
Returns:
the formatted currency amount
- Type
- String
Example
asCurrency(42.666)
=> '42.67 $'
asCurrency(42.666, 'de-DE', 'EUR')
=> '42,67 €'