Home > Article > Web Front-end > How to convert letters to lowercase in javascript
How to convert javascript letters to lowercase: 1. Use toLowerCase() function, syntax "string.toLowerCase()"; 2. Use toLocaleLowerCase() function to convert strings according to the local host language environment is lowercase.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
Method 1: Use toLowerCase() function
The toLowerCase() method is used to convert strings to lowercase. The syntax is as follows
string.toLowerCase()
Example:
var txt="HELLO WORLD!"; console.log(txt.toLowerCase());
Output:
Method 2: Use toLocaleLowerCase() function
toLocaleLowerCase() method converts a string to lowercase according to the locale of the local host. Local is determined based on the browser's language settings.
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.
Grammar:
string.toLocaleLowerCase()
Example:
var str="HELLO WORLD!"; console.log(txt.toLocaleLowerCase());
Output:
【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!