• JavaScript Video Tutorials

JavaScript String toLocaleLowerCase() Method



The JavaScript String toLocaleLowerCase() method in JavaScript returns a new string by converting the original string into lowercase letters using any locale-specific based on the language settings of the browser you are using. It does not modify the original string.

The toLocaleLowerCase() method in JavaScript returns the same result as the toLowerCase() method. The only difference is that the toLocaleLowerCase() method takes a locale as an optional parameter, whereas the toLowerCase() method does not.

Syntax

Following is the syntax of JavaScript String toLocaleLowerCase() method −

toLocaleLowerCase(locales)

Parameters

  • locales − The locale to be used to convert string to lowercase.

Return value

This method return a new string by converting them into lowercase using the specified locales.

Example 1

If we omit the locale parameter, this method simply converts the given strings into lowercase letters without using any locales, as it has not been specified.

<html>
<head>
<title>JavaScript String toLocaleLowerCase() Method</title>
</head>
<body>
<script>
   const str = "TUTORIALS POINT";
   document.write("Original string: ", str);
   document.write("<br>New string(lowercase): ", str.toLocaleLowerCase());
</script>    
</body>
</html>

Output

The above program returns a new string as "tutorials point".

Original string: TUTORIALS POINT
New string(lowercase): tutorials point

Example 2

The following is another example of the JavaScript String toLocaleLowerCase() method. In this example, we use this method to convert a given string "Hello World" into lowercase using the locale "EN-US".

<html>
<head>
<title>JavaScript String toLocaleLowerCase() Method</title>
</head>
<body>
<script>
   const str = "Hello World";
   const locale = "EN-US";
   document.write("Original string: ", str);
   document.write("<br>The locale is: ", locale);
   document.write("<br>New string(lowercase): ", str.toLocaleLowerCase(locale));
</script>    
</body>
</html>

Output

After executing the above program, it will return a new string as "hello world".

Original string: Hello World
The locale is: EN-US
New string(lowercase): hello world
Advertisements