JavaScript String toLocaleLowerCase() Method (original) (raw)
Last Updated : 16 Jul, 2024
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 errors, 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 `
// Input string let gfg = 'GeeKsForGeekS';
// Output with lowercase method console.log('EN-US: ' + gfg.toLocaleLowerCase('en-US')); console.log('TR: ' + gfg.toLocaleLowerCase('tr'));
// New input string let gfg1 = new String("String.prototype.toLocaleLowerCase()");
// Display output console.log('Result: ' + gfg1.toLocaleLowerCase());
`
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 `
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');
`
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 the String.prototype.toLocaleLowerCase() method are listed below:
- Google Chrome 41
- Edge 12
- Firefox 29
- Opera 28
- Safari 10