Conversion method: 1. Use toUpperCase() function, syntax "stringObject.toUpperCase()"; 2. Use toLocaleUpperCase() function, syntax "stringObject.toLocaleUpperCase()".
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
1. Use the toUpperCase() function to convert a string to uppercase.
The toUpperCase() method is used to convert a string to uppercase.
Syntax
stringObject.toUpperCase()
Return value
A new string in which all lowercase characters of stringObject are converted to uppercase characters.
Example
<script type="text/javascript"> var str="Hello World!" document.write(str.toUpperCase()) </script>
Output:
HELLO WORLD!
2. Use the toLocaleUpperCase() function to convert the string to uppercase
## The #toLocaleUpperCase() method is used to convert a string to uppercase. SyntaxstringObject.toLocaleUpperCase()
<script type="text/javascript"> var str="Hello World!" document.write(str.toLocaleUpperCase()) </script>
HELLO WORLD!
javascript advanced tutorial]
The above is the detailed content of How to convert string to uppercase in javascript. For more information, please follow other related articles on the PHP Chinese website!