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

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 compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
of
81
81
86
No
68
14.1
81
81
86
58
14.5
13.0

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/of