Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

JavaScript | Intl.ListFormat.supportedLocalesOf() Method

  • Last Updated : 18 Nov, 2021

The Intl.ListFormat.supportedLocalesOf() method is an inbuilt method in JavaScript which returns an array containing those of the provided locales that are supported in date and time formatting.
Syntax: 
 

Intl.ListFormat.supportedLocalesOf(locales, options)

Parameters: This method accept two parameters as mentioned above and described below: 
 

  • locales: This parameter holds a string with a BCP 47 language tag, or an array of such strings.
  • options: It is an optional parameter. It is an object that have localeMatcher property. localeMatcher is the locale matching algorithm to use. It has the values are “lookup” and “best fit”.

Return value: This method returns an array of strings representing the subset of the given locale tags that are supported in date and time formatting.
Below examples illustrate the Intl.ListFormat.supportedLocalesOf() method in JavaScript:
Example 1: 
 

javascript




<script>
const geeks = ['ban', 'id-u-co-pinyin', 'de-ID'];
const result = { localeMatcher: 'lookup' };
let val = Intl.ListFormat.supportedLocalesOf(geeks, result).join(', ');
console.log(val);
</script>

Output: 
 

"id-u-co-pinyin, de-ID"

Example 2: 
 

javascript




<script>
const geeks = ['ban', 'id-u-co-pinyin', 'de-ID'];
let val = Intl.ListFormat.supportedLocalesOf(geeks).join(', ');
console.log(val);
</script>

Output: 
 

"id-u-co-pinyin, de-ID"

Supported Browsers: The browsers supported by Intl.ListFormat.supportedLocalesOf() method are listed below: 
 

  • Google Chrome 72 and above
  • Edge 79 and above
  • Firefox 78 and above
  • Opera 60 and above
  • Safari 14.1 and above

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!