Intl.DisplayNames.prototype.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

Specification
Intl.DisplayNames
The definition of 'of()' in that specification.

Browser compatibility

DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
ofChrome Full support 81Edge Full support 81Firefox No support NoIE No support NoOpera Full support 68Safari No support NoWebView Android Full support 81Chrome Android Full support 81Firefox Android No support NoOpera Android Full support 58Safari iOS No support NoSamsung Internet Android No support Nonodejs Full support 14.0.0

Legend

Full support
Full support
No support
No support

See also