Intl.Locale.prototype.caseFirst property is an accessor property that returns whether case is taken into account for the locale's collation rules.

描述

A locale's collation rules are used to determine how strings are ordered in that locale. Certain locales use a character's case (UPPERCASE or lowercase) in the collation process. This additional rule can be expressed in a Locale's caseFirst 特性。

There are 3 values that the caseFirst property can have, outlined in the table below.

caseFirst

Value 描述
upper Upper case to be sorted before lower case.
lower Lower case to be sorted before upper case.
false No special case ordering.

范例

设置 caseFirst value via the locale string

Unicode locale string spec , the values that caseFirst represents correspond to the key kf . kf is treated as a locale string "extension subtag". These subtags add additional data about the locale, and are added to locale identifiers by using the -u extension key. Thus, the caseFirst value can be added to the inital locale identifier string that is passed into the Locale constructor. To add the caseFirst value, first add the -u extension key to the string. Next, add the -kf extension key to indicate that you are adding a value for caseFirst . Finally, add the caseFirst value to the string.

let caseFirstStr = new Intl.Locale("fr-Latn-FR-u-kf-upper");
console.log(caseFirstStr.caseFirst); // Prints "upper"
					

Setting the caseFirst value via the configuration object argument

Intl.Locale constructor has an optional configuration object argument, which can be used to pass extension types. Set the caseFirst property of the configuration object to your desired caseFirst value, and then pass it into the constructor.

let caseFirstObj= new Intl.Locale("en-Latn-US", {caseFirst: "lower"});
console.log(us12hour.caseFirst); // Prints "lower"
					

规范

规范
ECMAScript 国际化 API (ECMA-402)

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet Node.js
caseFirst Chrome 74 Edge 79 Firefox 75 IE No Opera 62 Safari 14 WebView Android 74 Chrome Android 74 Firefox Android No Opera Android 53 Safari iOS 14 Samsung Internet Android 11.0 nodejs 12.0.0
12.0.0
Before version 13.0.0, only the locale data for en-US is available by default. See the Locale() 构造函数 了解更多细节。

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

另请参阅

元数据

  • 最后修改: