In a previous section, we discussed the process of converting a string to lowercase using the toLowerCase function. It is important to note that when converting a string to lowercase, the outcome may differ based on language variations. For example, in Western languages, the letter 'i' transforms to 'I' when capitalized, whereas in Turkish, 'i' transforms to a dotted 'ı'. To address these language-specific issues, the toLocaleLowerCase function can be utilized.
The JavaScript method toLocaleLowerCase transforms a string into lowercase letters according to the locale of the host system. Generally, this method produces the same outcome as using the toLowerCase method.
Syntax
The syntax for the toLocaleLowerCase method is as follows:
string. toLocaleLowerCase()
Returns
A sequence of lowercase characters determined by the host's current locale setting.
JavaScript String toLocaleLowerCase Method Example
Let's explore a few basic illustrations of the toLocaleLowerCase function.
Example 1
In this section, we will display the provided string using lowercase characters.
<script>
var str="Example";
document.writeln(str.toLocaleLowerCase());
</script>
Output:
Example
Example 2
Let's explore another illustration demonstrating how to output the provided string in lowercase format.
<script>
var str=new String("Example");
document.writeln(str.toLocaleLowerCase());
</script>
Output:
Example