Intl.DisplayNames.prototype.of()

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

BCD tables only load in the browser

See also