The resolvedOptions()
method of Intl.NumberFormat instances returns a new object with properties reflecting the locale and number formatting options computed during initialization of this Intl.NumberFormat
object.
Syntax
resolvedOptions()
Parameters
None.
Return value
A new object with properties reflecting the locale and number formatting options computed during the construction of the given Intl.NumberFormat object.
The resulting object has the following properties:
compactDisplay
- : Whether to use short or long form when using compact notation.
This is the value provided in the
options.compactDisplay
argument of the constructor, or the default value:"short"
. The value is only present ifnotation
is set to "compact", and otherwise isundefined
.
- : Whether to use short or long form when using compact notation.
This is the value provided in the
currency
- : The currency to use in currency formatting.
The value is defined if
style
is"currency"
, and is otherwiseundefined
. This is the value provided in theoptions.currency
argument of the constructor.
- : The currency to use in currency formatting.
The value is defined if
currencyDisplay
- : The display format for the currency, such as a symbol, or currency code.
The value is defined if
style
is"currency"
, and otherwise isundefined
. This is the value provided in theoptions.currencyDisplay
argument of the constructor, or the default value:"symbol"
.
- : The display format for the currency, such as a symbol, or currency code.
The value is defined if
currencySign
- : The method used to specify the sign of the currency value:
standard
oraccounting
. The value is present ifstyle
is"currency"
, and otherwise isundefined
. This is the value provided in theoptions.currencySign
argument of the constructor, or the default value:"standard"
.
- : The method used to specify the sign of the currency value:
locale
- : The BCP 47 language tag for the locale that was actually used.
The key-value pairs that were requested in the constructor
locale
and are supported for this locale are included.
- : The BCP 47 language tag for the locale that was actually used.
The key-value pairs that were requested in the constructor
notation
- : The formatting that should be applied to the number, such as
standard
orengineering
. This is the value provided in theoptions.notation
argument of the constructor, or the default value:"standard"
.
- : The formatting that should be applied to the number, such as
numberingSystem
- : The numbering system.
This is the value provided in the
options.numberingSystem
argument of the constructor, if present, or the value set using the Unicode extension keynu
, or filled in as a default.
- : The numbering system.
This is the value provided in the
roundingMode
- : The rounding mode.
This is the value provided for the
options.roundingMode
argument in the constructor, or the default value:halfExpand
.
- : The rounding mode.
This is the value provided for the
roundingPriority
- : The priority for resolving rounding conflicts if both "FractionDigits" and "SignificantDigits" are specified.
This is the value provided for the
options.roundingPriority
argument in the constructor, or the default value:auto
.
- : The priority for resolving rounding conflicts if both "FractionDigits" and "SignificantDigits" are specified.
This is the value provided for the
roundingIncrement
- : The rounding-increment precision (the increment used when rounding numbers).
This is the value specified in the
options.roundingIncrement
argument in the constructor.
- : The rounding-increment precision (the increment used when rounding numbers).
This is the value specified in the
signDisplay
- : Whether or not to display the positive/negative sign.
This is the value specified in the
options.signDisplay
argument in the constructor, or the default value:"auto"
.
- : Whether or not to display the positive/negative sign.
This is the value specified in the
unit
- : The unit to use in unit formatting.
The value is only present if
style
is"unit"
, and is otherwiseundefined
. This is the value specified in theoptions.unit
argument in the constructor.
- : The unit to use in unit formatting.
The value is only present if
unitDisplay
- : The display format to use for units in unit formatting, such as "long", "short" or "narrow".
The value is only present if
style
is"unit"
, and is otherwiseundefined
. This is the value specified in theoptions.unitDisplay
argument in the constructor, or the default value:short
.
- : The display format to use for units in unit formatting, such as "long", "short" or "narrow".
The value is only present if
useGrouping
- : Whether or not to use grouping separators to indicate "thousands", "millions" and son on.
This is the value specified in the
options.useGrouping
argument in the constructor, or the default value:"auto"
.
- : Whether or not to use grouping separators to indicate "thousands", "millions" and son on.
This is the value specified in the
trailingZeroDisplay
- : The strategy for displaying trailing zeros on whole numbers.
This is the value specified in the
options.trailingZeroDisplay
argument in the constructor, or the default value:"auto"
.
- : The strategy for displaying trailing zeros on whole numbers.
This is the value specified in the
Only one of the following two groups of properties is included:
minimumIntegerDigits
,minimumFractionDigits
,maximumFractionDigits
- : The values provided for these properties in the
options
argument or filled in as defaults. These properties are present only if neitherminimumSignificantDigits
normaximumSignificantDigits
was provided in theoptions
argument.
- : The values provided for these properties in the
minimumSignificantDigits
,maximumSignificantDigits
- : The values provided for these properties in the
options
argument or filled in as defaults. These properties are present only if at least one of them was provided in theoptions
argument.
- : The values provided for these properties in the
Examples
Using the resolvedOptions
method
// Create a NumberFormat
const de = new Intl.NumberFormat("de-DE", {
style: "currency",
currency: "USD",
maximumFractionDigits: 2,
roundingIncrement: 5,
roundingMode: "halfCeil",
});
// Resolve the options
const usedOptions = de.resolvedOptions();
console.log(usedOptions.locale); // "de-DE"
console.log(usedOptions.numberingSystem); // "latn"
console.log(usedOptions.compactDisplay); // undefined ("notation" not set to "compact")
console.log(usedOptions.currency); // "USD"
console.log(usedOptions.currencyDisplay); // "symbol"
console.log(usedOptions.currencySign); // "standard"
console.log(usedOptions.minimumIntegerDigits); // 1
console.log(usedOptions.minimumFractionDigits); // 2
console.log(usedOptions.maximumFractionDigits); // 2
console.log(usedOptions.minimumSignificantDigits); // undefined (maximumFractionDigits is set)
console.log(usedOptions.maximumSignificantDigits); // undefined (maximumFractionDigits is set)
console.log(usedOptions.notation); // "standard"
console.log(usedOptions.roundingIncrement); // 5
console.log(usedOptions.roundingMode); // halfCeil
console.log(usedOptions.roundingPriority); // auto
console.log(usedOptions.signDisplay); // "auto"
console.log(usedOptions.style); // "currency"
console.log(usedOptions.trailingZeroDisplay); // auto
console.log(usedOptions.useGrouping); // auto