API · JavaScript
JavaScript string.toLocaleLowerCase() Method
JavaScript string.toLocaleLowerCase() is a built-in method that converts a given string to lowercase based on the locale-specific case mappings. When multiple locales exist in an array, the toLocaleLowerCase() method chooses the best available locale.
On this page
The string.toLocaleLowerCase() method converts the characters of a given string into lowercase according to any locale-specific case mappings. The host’s current locale is set as the default locale.
In the toLocaleLowerCase() method, there is no parameter. However, users can choose from BCP 47 language tags to set a locale parameter.
Syntax of JavaScript string.toLocaleLowerCase():
referenceString.toLocaleLowerCase();
referenceString.toLocaleLowerCase(locale);
Parameter
locale |
To specify a locale that should be used to convert the characters of a string into lowercase. |
Return
It returns the given string in lowercase based on the locale-specific case mappings.
Example Codes: Use the string.toLocaleLowerCase() Method to Convert a String to Lowercase
The string.toLocaleLowerCase() method can convert a string to lowercase without any parameter. If some strings are not converting according to locale-specific case mapping, we can choose from BCF 47 language tags to specify a locale parameter.
In this example, we have not passed any parameter in the string.toLocaleLowerCase() method.
let string = 'CAFÉ';
let lwStr = string.toLocaleLowerCase();
console.log(lwStr);
Output:
café
Example Codes: Use the string.toLocaleLowerCase() Method to Specify a locale for the New String
We might get different outputs while working on a host of distant locations or using an old-version browser. Hence, you can specify a locale parameter by selecting it from the BCF 47 language tags.
In the example below, we have passed an fr-FR (French Locale) to the locale parameter in the string.toLocaleLowerCase() method to see the output.
var string = 'Select Français or Español language.';
let frStr = string.toLocaleLowerCase('fr-FR');
console.log(frStr);
Output:
select français or español language.
The string.toLocaleLowerCase() method converts the text of a string into lowercase according to the locale-specific case mappings. By default, the method will use the locale of the host.
Although string.toLocaleLowerCase() and string.toLowerCase() give similar output, both the methods are used for different purposes.