このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

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 2021年4月.

resolvedOptions()Intl.ListFormat インスタンスのメソッドで、現在の ListFormat オブジェクトの構築時に計算されたロケールとスタイル整形オプションを反映したプロパティを持つ新しいオブジェクトを返します。

試してみましょう

const deListFormatter = new Intl.ListFormat("de-DE", { type: "disjunction" });
const options = deListFormatter.resolvedOptions();

console.log(options.locale);
// 予想される結果: "de-DE"

console.log(options.style);
// 予想される結果: "long"

console.log(options.type);
// 予想される結果: "disjunction"

構文

js
resolvedOptions()

引数

なし。

返値

指定された Intl.ListFormat オブジェクトの構築時に計算されたロケールと整形オプションを反映したプロパティを持つオブジェクトです。

locale

実際に使用されているロケールの BCP 47 言語タグです。これは、ロケールネゴシエーションのプロセスによって決定されます。出力には、Unicode 拡張キーは記載されません。

type

options 引数でこのプロパティに指定された値です。値は "conjunction""disjunction""unit" のいずれかです。デフォルト値は "conjunction" です。

style

options 引数でこのプロパティに指定された値です。必要に応じてデフォルト値が設定されます。値は "long""short""narrow" のいずれかです。デフォルト値は "long" です。

resolvedOptions の使用

js
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" (デフォルト値)

仕様書

Specification
ECMAScript® 2027 Internationalization API Specification
# sec-Intl.ListFormat.prototype.resolvedoptions

ブラウザーの互換性

関連情報