Since April 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The resolvedOptions() method of Intl.Segmenter instances returns a new object with properties reflecting the options computed during initialization of this Segmenter object.
const segmenter = new Intl.Segmenter("fr-FR");
const options = segmenter.resolvedOptions();
console.log(options.locale);
// Expected output: "fr-FR"
console.log(options.granularity);
// Expected output: "grapheme"
resolvedOptions()
None.
A new object with properties reflecting the options computed during the initialization of this Segmenter object. The object has the following properties, in the order they are listed:
localeThe BCP 47 language tag for the locale actually used, determined by the locale negotiation process. No Unicode extension key will be included in the output.
granularityThe value provided for this property in the options argument, with default filled in as needed. It is either "grapheme", "word", or "sentence". The default is "grapheme".
const spanishSegmenter = new Intl.Segmenter("es", { granularity: "sentence" });
const options = spanishSegmenter.resolvedOptions();
console.log(options.locale); // "es"
console.log(options.granularity); // "sentence"
const spanishSegmenter = new Intl.Segmenter("es");
const options = spanishSegmenter.resolvedOptions();
console.log(options.locale); // "es"
console.log(options.granularity); // "grapheme"
const banSegmenter = new Intl.Segmenter("ban");
const options = banSegmenter.resolvedOptions();
console.log(options.locale);
// "fr" on a runtime where the Balinese locale
// is not supported and French is the default locale
console.log(options.granularity); // "grapheme"
| Desktop | Mobile | Server | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | Bun | Deno | Node.js | |
resolvedOptions |
87 | 87 | 125 | 73 | 14.1 | 87 | 125 | 62 | 14.5 | 14.0 | 87 | 14.5 | 1.0.0 | 1.8 | 16.0.0 |
© 2005–2025 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/Segmenter/resolvedOptions