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.
On this page
Intl.NumberFormat.prototype.resolvedOptions()
Try it
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.compactDisplayargument of the constructor, or the default value:"short". The value is only present ifnotationis set to "compact", and otherwise isundefined. -
currency -
The currency to use in currency formatting. The value is defined if
styleis"currency", and is otherwiseundefined. This is the value provided in theoptions.currencyargument of the constructor. -
currencyDisplay -
The display format for the currency, such as a symbol, or currency code. The value is defined if
styleis"currency", and otherwise isundefined. This is the value provided in theoptions.currencyDisplayargument of the constructor, or the default value:"symbol". -
currencySign -
The method used to specify the sign of the currency value:
standardoraccounting. The value is present ifstyleis"currency", and otherwise isundefined. This is the value provided in theoptions.currencySignargument of the constructor, or the default value:"standard". -
locale -
The BCP 47 language tag for the locale that was actually used. The key-value pairs that were requested in the constructor
localeand are supported for this locale are included. -
notation -
The formatting that should be applied to the number, such as
standardorengineering. This is the value provided in theoptions.notationargument of the constructor, or the default value:"standard". -
numberingSystem -
The numbering system. This is the value provided in the
options.numberingSystemargument of the constructor, if present, or the value set using the Unicode extension keynu, or filled in as a default. -
roundingMode -
The rounding mode. This is the value provided for the
options.roundingModeargument in the constructor, or the default value:halfExpand. -
roundingPriority -
The priority for resolving rounding conflicts if both "FractionDigits" and "SignificantDigits" are specified. This is the value provided for the
options.roundingPriorityargument in the constructor, or the default value:auto. -
roundingIncrement -
The rounding-increment precision (the increment used when rounding numbers). This is the value specified in the
options.roundingIncrementargument in the constructor. -
signDisplay -
Whether or not to display the positive/negative sign. This is the value specified in the
options.signDisplayargument in the constructor, or the default value:"auto". -
unit -
The unit to use in unit formatting. The value is only present if
styleis"unit", and is otherwiseundefined. This is the value specified in theoptions.unitargument in the constructor. -
unitDisplay -
The display format to use for units in unit formatting, such as "long", "short" or "narrow". The value is only present if
styleis"unit", and is otherwiseundefined. This is the value specified in theoptions.unitDisplayargument in the constructor, or the default value:short. -
useGrouping -
Whether or not to use grouping separators to indicate "thousands", "millions" and son on. This is the value specified in the
options.useGroupingargument in the constructor, or the default value:"auto". -
trailingZeroDisplay -
The strategy for displaying trailing zeros on whole numbers. This is the value specified in the
options.trailingZeroDisplayargument in the constructor, or the default value:"auto".
Only one of the following two groups of properties is included:
minimumIntegerDigits,minimumFractionDigits,maximumFractionDigits-
The values provided for these properties in the
optionsargument or filled in as defaults. These properties are present only if neitherminimumSignificantDigitsnormaximumSignificantDigitswas provided in theoptionsargument. minimumSignificantDigits,maximumSignificantDigits-
The values provided for these properties in the
optionsargument or filled in as defaults. These properties are present only if at least one of them was provided in theoptionsargument.
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
Specifications
Browser compatibility
| Desktop | Mobile | Server | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | Deno | Node.js | ||
resolvedOptions |
24 | 12 | 29 | 15 | 10 | 25 | 56 | 14 | 10 | 1.5 | 4.4 | 1.8 |
0.12.0Before version 13.0.0, only the locale data foren-US is available by default. See the NumberFormat() constructor for more details.
|
|
result_roundingIncrement_property |
106 | 106 | 116 | 92 | 16.4 | 106 | 116 | 72 | 16.4 | 20.0 | 106 | No | 19.0.0 | |
result_roundingMode_property |
106 | 106 | 116 | 92 | 16.4 | 106 | 116 | 72 | 16.4 | 20.0 | 106 | No | 19.0.0 | |
result_roundingPriority_property |
106 | 106 | 116 | 92 | 16.4 | 106 | 116 | 72 | 16.4 | 20.0 | 106 | No | 19.0.0 | |
result_signDisplay_property |
106 | 106 | 116 | 92 | 16.4 | 106 | 116 | 72 | 16.4 | 20.0 | 106 | No | 19.0.0 | |
result_trailingZeroDisplay_property |
106 | 106 | 116 | 92 | 16.4 | 106 | 116 | 72 | 16.4 | 20.0 | 106 | No | 19.0.0 | |
result_useGrouping_property |
106 | 106 | 116 | 92 | 16.4 | 106 | 116 | 72 | 16.4 | 20.0 | 106 | No | 19.0.0 | |
See also
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/resolvedOptions