Open In App

JavaScript Intl ListFormat supportedLocalesOf() Method

The Intl.ListFormat.supportedLocalesOf() method is an inbuilt method in JavaScript that returns an array containing those of the provided locales that are supported in list formatting.

Syntax: 



Intl.ListFormat.supportedLocalesOf(locales, options)

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

Return value: This method returns an array of strings representing the subset of the given locale tags that are supported in list formatting.



The below examples illustrate the Intl.ListFormat.supportedLocalesOf() method in JavaScript:

Example 1: In this example, we will see the basic use of the Intl.ListFormat.supportedLocalesOf() method in 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: In this example, we will see the basic use of the Intl.ListFormat.supportedLocalesOf() method in 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"

We have a complete list of Javascript Intl methods, to check those please go through the Javascript Intl Complete Reference article.

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

Article Tags :