Skip to content
Related Articles
Open in App
Not now

Related Articles

JavaScript String.prototype.toLocaleLowerCase() Method

Improve Article
Save Article
  • Last Updated : 27 Dec, 2022
Improve Article
Save Article

The String.prototype.toLocaleLowerCase() method in JavaScript is a Standard built-in object which returns the calling string value converted to a lowercase letter on the basis of the host’s current locale. 

Syntax:

str.toLocaleLowerCase()
str.toLocaleLowerCase(locale) 

Parameters:

  • locale: It is an optional parameter and it indicates the locale to be used to convert to lowercase according to any locale-specific case mappings.

Returns Value: This method returns a string of lowercase letters. 

Exceptions: This method gives two kinds of error, which are as follows:

  • RangeError: If the locale argument isn’t a valid language tag.
  • TypeError: If an array element isn’t of type string.

The below examples illustrate the String.prototype.toLocaleLowerCase() method in JavaScript: 

Example 1: In this example, we will convert the uppercase string to a lowercase string and console it using the String.prototype.toLocaleLowerCase() method in JavaScript.

javascript




<script>
    const gfg = 'GeeKsForGeekS';
    console.log('EN-US: ' + gfg.toLocaleLowerCase('en-US'));
    console.log('TR: ' + gfg.toLocaleLowerCase('tr'));
      
    const gfg1 = new String("String.prototype.toLocaleLowerCase()");
    console.log('Result: ' + gfg1.toLocaleLowerCase());
</script>

Output:

"EN-US: geeksforgeeks"
"TR: geeksforgeeks"
"Result: string.prototype.tolocalelowercase()"

Example 2: In this example, we will convert the uppercase string to a lowercase string and console it using the String.prototype.toLocaleLowerCase() method in JavaScript.

javascript




<script>
    console.log('ALPHABET'.toLocaleLowerCase());
      
    console.log('\u0130'.toLocaleLowerCase('tr') === 'i');
    console.log('\u0130'.toLocaleLowerCase('en-US') === 'i');
      
    let geeks = ['tr', 'TR', 'tr-TR', 'tr-u-co-search', 'tr-x-turkish'];
    console.log('\u0130'.toLocaleLowerCase(geeks) === 'i');
</script>

Output:

"alphabet"
true
false
true

We have a complete list of Javascript String methods, to check those please go through this JavaScript String Complete Reference article.

Supported Browsers: The browsers supported by String.prototype.toLocaleLowerCase() method are listed below:

  • Google Chrome
  • Firefox
  • IE
  • Opera
  • Safari
  • Edge

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!