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.

Try it

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 Server
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet Deno Node.js
of
81
81
86
No
68
14.1
81
81
86
58
14.5
13.0
1.8
14.0.0

See also

© 2005–2022 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