W3cubDocs

/JavaScript

Intl.displayNames.of

The of() method receives a code and returns a string based on the locale and options provided when instantiating Intl.DisplayNames.

Syntax

displayNames.of(code);

Parameters

code
The code to provide depends on the type:

Return value

A language-specific formatted string.

Examples

Using the of method

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"

Specifications

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
of 81 81 No No 68 No
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
of 81 81 No 58 No No
Server
Node.js
of 14.0.0

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/of