JavaScript String toLocaleLowerCase()
Syntax & Examples


String.toLocaleLowerCase() method

The toLocaleLowerCase() method of the String class in JavaScript converts the characters within a string to lowercase while respecting the current locale or the specified locale.


Syntax of String.toLocaleLowerCase()

There are 2 variations for the syntax of String.toLocaleLowerCase() method. They are:

1.
toLocaleLowerCase()

This method converts the characters within the string to lowercase according to the current locale.

Returns value of type String.

2.
toLocaleLowerCase(locales)

Parameters

ParameterOptional/RequiredDescription
localesoptionalA string with a BCP 47 language tag, or an array of such strings. This affects the locale to be used during the conversion.

This method converts the characters within the string to lowercase according to the specified locale.

Returns value of type String.



✐ Examples

1 Using toLocaleLowerCase() method with no arguments

In JavaScript, if no arguments are provided to the toLocaleLowerCase() method, it converts the string to lowercase according to the current locale.

For example,

  1. We define a string variable str with the value 'HELLO'.
  2. We use the toLocaleLowerCase() method with no arguments.
  3. The result is stored in the variable newStr.
  4. We log newStr to the console using the console.log() method.

JavaScript Program

const str = 'HELLO';
const newStr = str.toLocaleLowerCase();
console.log(newStr);

Output

hello

2 Using toLocaleLowerCase() method with a single locale argument

In JavaScript, we can use the toLocaleLowerCase() method with a specified locale to convert the string to lowercase.

For example,

  1. We define a string variable str with the value 'İSTANBUL'.
  2. We use the toLocaleLowerCase() method with the argument 'tr' for Turkish locale.
  3. The result is stored in the variable newStr.
  4. We log newStr to the console using the console.log() method.

JavaScript Program

const str = 'İSTANBUL';
const newStr = str.toLocaleLowerCase('tr');
console.log(newStr);

Output

istanbul

3 Using toLocaleLowerCase() method with multiple locale arguments

In JavaScript, we can specify multiple locales to the toLocaleLowerCase() method to ensure proper case conversion for multiple languages.

For example,

  1. We define a string variable str with the value 'HELLO'.
  2. We use the toLocaleLowerCase() method with the arguments 'en-US' and 'tr'.
  3. The result is stored in the variable newStr.
  4. We log newStr to the console using the console.log() method.

JavaScript Program

const str = 'HELLO';
const newStr = str.toLocaleLowerCase(['en-US', 'tr']);
console.log(newStr);

Output

hello

Summary

In this JavaScript tutorial, we learned about toLocaleLowerCase() method of String: the syntax and few working examples with output and detailed explanation for each example.