Intl.ListFormat.prototype.resolvedOptions() 方法是 JavaScript 中的一個內置方法,它返回一個新對象,該對象具有反映在當前 ListFormat 對象構建期間計算的區域設置和樣式格式選項的屬性。
用法:
listFormat.resolvedOptions()
參數:此方法不接受任何參數。
返回值:此方法返回一個對象,該對象具有反映在給定 ListFormat 對象的構造過程中計算的區域設置和格式選項的屬性。
下麵的例子說明了 JavaScript 中的 Intl.ListFormat.prototype.resolvedOptions() 方法:
範例1:
<script>
const geeks = new Intl.ListFormat("de-DE", { style:"short" });
const result = geeks.resolvedOptions();
console.log(result.locale);
console.log(result.style);
console.log(result.type);
</script>
輸出:
"de" "short" "conjunction"
範例2:
<script>
const geeks = new Intl.ListFormat("hi");
const result = geeks.resolvedOptions();
console.log(result.locale);
console.log(result.style);
console.log(result.type);
console.log(result.collation);
console.log(result.numeric);
</script>
輸出:
"hi" "long" "conjunction" undefined undefined
支持的瀏覽器: Intl.ListFormat.prototype.resolvedOptions() 方法支持的瀏覽器如下:
- 穀歌瀏覽器
- Opera
相關用法
- Javascript dataView.getInt16()用法及代碼示例
- Javascript RegExp toString()用法及代碼示例
- JavaScript Date toLocaleTimeString()用法及代碼示例
- JavaScript Math random()用法及代碼示例
- JavaScript Math round()用法及代碼示例
- Javascript toFixed()用法及代碼示例
注:本文由純淨天空篩選整理自SHUBHAMSINGH10大神的英文原創作品 JavaScript | Intl.ListFormat.prototype.resolvedOptions() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。