Home > Article > Web Front-end > How to convert letters to lowercase in javascript
Javascript method to convert letters to lowercase: 1. Use toLowerCase(), the syntax "string.toLowerCase()"; 2. Use toLocaleLowerCase(), the syntax "string.toLocaleLowerCase()".
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
javascript converts letters to lowercase
Method 1: Use toLowerCase() method
The toLowerCase() method is used to convert a string to lowercase. The specific syntax format is as follows:
string.toLowerCase()
Example:
<script type="text/javascript"> console.log("A".toLowerCase()); console.log("B".toLowerCase()); console.log("C".toLowerCase()); </script>
Output result:
Method 2 : Use the toLocaleLowerCase() method
toLocaleLowerCase() method to convert the string to lowercase according to the local host's locale. The specific syntax format is as follows:
string.toLocaleLowerCase()
Generally, this method returns the same result as the toLowerCase() method. Only a few languages (such as Turkish) have local-specific case mapping.
Note: The toLocaleLowerCase() method does not change the original string.
Example:
<script type="text/javascript"> document.write("P".toLocaleLowerCase()); document.write("H".toLocaleLowerCase()); document.write("P".toLocaleLowerCase()); </script>
Output result:
[Recommended learning: javascript advanced tutorial]
The above is the detailed content of How to convert letters to lowercase in javascript. For more information, please follow other related articles on the PHP Chinese website!