Intl.ListFormat.prototype.resolvedOptions()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.
Die resolvedOptions()
Methode von Intl.ListFormat
Instanzen gibt ein neues Objekt mit Eigenschaften zurück, die die während der Initialisierung dieses ListFormat
-Objekts berechneten Optionen widerspiegeln.
Probieren Sie es aus
const deListFormatter1 = new Intl.ListFormat("de-DE", { type: "disjunction" });
const options1 = deListFormatter1.resolvedOptions();
console.log(options1.locale);
// Expected output (Firefox / Safari): "de-DE"
// Expected output (Chrome): "de"
console.log(options1.style);
// Expected output: "long"
console.log(options1.type);
// Expected output: "disjunction"
Syntax
resolvedOptions()
Parameter
Keine.
Rückgabewert
Ein neues Objekt mit Eigenschaften, die die während der Initialisierung dieses ListFormat
-Objekts berechneten Optionen widerspiegeln. Das Objekt hat die folgenden Eigenschaften, in der Reihenfolge, in der sie aufgeführt sind:
locale
-
Das BCP 47 Sprach-Tag für das tatsächlich verwendete Gebietsschema, ermittelt durch den Locale-Aushandlungsprozess. Kein Unicode-Erweiterungsschlüssel wird in der Ausgabe enthalten sein.
type
-
Der in der
options
-Argument übergebene Wert für diese Eigenschaft, mit Standardwerten, die bei Bedarf ausgefüllt werden. Es ist entweder"conjunction"
,"disjunction"
oder"unit"
. Der Standardwert ist"conjunction"
. style
-
Der in der
options
-Argument übergebene Wert für diese Eigenschaft, mit Standardwerten, die bei Bedarf ausgefüllt werden. Es ist entweder"long"
,"short"
oder"narrow"
. Der Standardwert ist"long"
.
Beispiele
Verwendung von resolvedOptions
const deListFormatter = new Intl.ListFormat("de-DE", { style: "short" });
const usedOptions = de.resolvedOptions();
console.log(usedOptions.locale); // "de-DE"
console.log(usedOptions.style); // "short"
console.log(usedOptions.type); // "conjunction" (the default value)
Spezifikationen
Specification |
---|
ECMAScript® 2026 Internationalization API Specification # sec-Intl.ListFormat.prototype.resolvedoptions |