JavaScript > String Methods

ToLocaleLowerCase() String in JavaScript

How to convert the string to lowercase letters in JavaScript?

By using toLocaleLowerCase() we can convert the string to lowercase letters.

<p>Click the below button to Convert.</p>
<input type="button" value="Convert" onclick="Function()" />
<p id="myId"></p>

    function Function() {
        var A = "TECHFUNDA";
        var r = A.toLocaleLowerCase();
        document.getElementById("myId").innerHTML = r;

In the above code snippet we have given Id to the second <p> element in the HTML code, there is a string in uppercase letters with variable A in the <script>code. We need to convert the uppercase letters in a string to the lowercase letters, for that we use string method toLocaleLowerCase(). Onclick of the button "Convert" fires the Function() in the <script> code at the same time toLocaleLowerCase() method converts the uppercase letters to the lowercase letters and gives the output.

This gives the same output as toLowerCase however where the language conflict with the Unicode case mappings occurs, we can use toLocaleLowerCase instead of toLowerCase.


 Views: 1049 | Post Order: 78

Write for us