JS method to convert lowercase letters to uppercase: 1. Use toUpperCase() function, syntax "string.toUpperCase()"; 2. Use toLocaleUpperCase() function, syntax "string.toLocaleUpperCase()".
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
javascript method to convert lowercase letters to uppercase
Method 1: Use toUpperCase()
toUpperCase() method is used to convert strings to uppercase.
Syntax:
string.toUpperCase()
Return value: a new string in which all lowercase characters of string are converted to uppercase characters.
var str="Hello World!" document.write(str.toUpperCase())
Method 2: Use toLocaleUpperCase()
toLocaleUpperCase() method is used to convert strings to uppercase.
Syntax:
string.toLocaleUpperCase()
Return value: a new string in which all lowercase characters of string are converted to uppercase characters.
Note: The toLocaleUpperCase() method converts the string to uppercase according to the local method. Only a few languages (such as Turkish) have local case mapping, so the return value of this method is usually the same as toUpperCase().
var str="Hello World!" console.log(str.toLocaleUpperCase());
【Related recommendations: javascript learning tutorial】
The above is the detailed content of How to convert lowercase letters to uppercase in javascript. For more information, please follow other related articles on the PHP Chinese website!