The resolvedOptions() method of Intl.Collator instances returns a new object with properties reflecting the options computed during initialization of this Collator object.
JavaScript Demo: Intl.Collator.prototype.resolvedOptions()
const collator = new Intl.Collator("de-DE", { sensitivity: "base" });
const options = collator.resolvedOptions();
console.log(options.sensitivity);
// Expected output: "base"
console.log(options.usage);
// Expected output: "sort"
Syntax
resolvedOptions()
Parameters
None.
Return value
A new object with properties reflecting the options computed during the initialization of this Collator object. The object has the following properties, in the order they are listed:
locale- : The BCP 47 language tag for the locale actually used, determined by the locale negotiation process. Only the
co,kn, andkfUnicode extension keys, if requested and supported, may be included in the output.
- : The BCP 47 language tag for the locale actually used, determined by the locale negotiation process. Only the
usage- : The value provided for this property in the
optionsargument, with default filled in as needed. It is either"sort"or"search". The default is"sort".
- : The value provided for this property in the
sensitivity- : The value provided for this property in the
optionsargument, with default filled in as needed. It is either"base","accent","case", or"variant". The default is"variant"for usage"sort"; it's locale dependent for usage"search".
- : The value provided for this property in the
ignorePunctuation- : The value provided for this property in the
optionsargument, with default filled in as needed. It is a boolean. The default istruefor Thai (th) andfalsefor all other languages.
- : The value provided for this property in the
collation- : The value provided for this property in the
optionsargument, or using the Unicode extension key"co", with default filled in as needed. It is a supported collation type for this locale. The default is"default".
- : The value provided for this property in the
numeric- : The value provided for this property in the
optionsargument, or using the Unicode extension key"kn", with default filled in as needed. It is a boolean. The default isfalse. If the implementation does not support this Unicode extension key, this property is omitted.
- : The value provided for this property in the
caseFirst- : The value provided for this property in the
optionsargument, or using the Unicode extension key"kf", with default filled in as needed. It is either"upper","lower", or"false". The default is"false". If the implementation does not support this Unicode extension key, this property is omitted.
- : The value provided for this property in the
Examples
Using the resolvedOptions method
const de = new Intl.Collator("de", { sensitivity: "base" });
const usedOptions = de.resolvedOptions();
usedOptions.locale; // "de"
usedOptions.usage; // "sort"
usedOptions.sensitivity; // "base"
usedOptions.ignorePunctuation; // false
usedOptions.collation; // "default"
usedOptions.numeric; // false
Specifications
Browser compatibility
See also
- Intl.Collator
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
