of
()
method receives a code and returns a string based on the locale and options provided when instantiating Intl.DisplayNames.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
displayNames.of(code);
code
code
to provide depends on the
type
:
A language-specific formatted string.
of
方法
let regionNames = new Intl.DisplayNames(['en'], {type: 'region'});
regionNames.of('419'); // "Latin America"
let languageNames = new Intl.DisplayNames(['en'], {type: 'language'});
languageNames.of('fr'); // "French"
let currencyNames = new Intl.DisplayNames(['en'], {type: 'currency'});
currencyNames.of('EUR'); // "Euro"
| 规范 |
|---|
|
Intl.DisplayNames
The definition of 'of()' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
of
|
Chrome 81 | Edge 81 | Firefox No | IE No | Opera 68 | Safari No | WebView Android 81 | Chrome Android 81 | Firefox Android No | Opera Android 58 | Safari iOS No | Samsung Internet Android No | nodejs 14.0.0 |
完整支持
不支持
Intl
Collator
DateTimeFormat
ListFormat
NumberFormat
PluralRules
RelativeTimeFormat
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()