Home > Article > Web Front-end > How to convert uppercase letters to lowercase in javascript
Javascript method to convert uppercase letters to lowercase: 1. Use toLowerCase(), syntax "string.toLowerCase()"; 2. Use toLocaleLowerCase(), syntax "string.toLocaleLowerCase()".
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
Javascript method to convert uppercase letters to lowercase:
Method 1: Use toLowerCase()
toLowerCase() method is used to convert strings to lowercase.
Syntax:
string.toLowerCase()
Return value:
A new string in which all uppercase characters in string are converted to lowercase characters.
var str="HELLO WORLD!" document.write(str.toLowerCase())
Method 2: Use toLocaleLowerCase()
toLocaleLowerCase() method according to the language of the local host The environment converts the string to lowercase. Local is determined based on the browser's language settings.
Syntax:
string.toLocaleLowerCase()
Return value:
A new string in which all uppercase characters of string are converted to Lowercase characters.
var str="HELLO WORLD!" console.log(str.toLocaleLowerCase());
Note:
Different from toLowerCase(), the toLocaleLowerCase() method converts the string to lower case. Only a few languages (such as Turkish) have local case mapping, so the return value of this method is usually the same as toLowerCase().
[Related recommendations: javascript learning tutorial]
The above is the detailed content of How to convert uppercase letters to lowercase in javascript. For more information, please follow other related articles on the PHP Chinese website!