Example of getting started with the toUpperCase method of a JavaScript string object (used to convert letters into uppercase) and touppercase
JavaScript toUpperCase Method
The toUpperCase method is used to convert (English) strings into uppercase and return the converted strings. The syntax is as follows:
Copy codeThe Code is as follows:
Str_object.toUpperCase ()
ToUpperCase method example
Copy codeThe Code is as follows:
<Script language = "JavaScript">
Var str = "AaBbCc ";
Document. write (str. toUpperCase ());
</Script>
Run this example and output:
Copy codeThe Code is as follows:
AABBCC
ToLocaleUpperCase Method
The toLocaleUpperCase method is basically the same as the toUpperCase method. toLocaleUpperCase converts the string to uppercase according to the local method. Only a few languages (such as Turkish) have local-specific case ing.
In JavaScript, how can I convert uppercase letters in strings to lowercase letters and convert lowercase letters to uppercase letters?
Example:
Function funZhuanHuanDaXiaoXie (str)
{
Var ar = str. split ('');
For (var I = 0; I <ar. length; I ++)
{
If (ar [I]. charCodeAt (0)> = 65 & ar [I]. charCodeAt (0) <= 90)
{
Ar [I]. toLowerCase ();
}
Else
{
Ar [I]. toUpperCase ();
}
} // All conversions have been made here;
Str = "";
For (var I = 0; I <ar. length; I ++)
{
Str + = ar [I];
}
Reture str;
}
The landlord can use the method I wrote to convert it, for example:
Var text = "IUHIUUskuisudin ";
Call this method conversion (you can set the method name as you like ):
Text = funZhuanHuanDaXiaoXie (text );
Java uses the toUpperCase () and toLowerCase () Methods of the String class to convert the case sensitivity of strings.
If it is for this specific string, it is easy to do.
First
String str = "ABCdef ";
String str1 = str. subString (3 );
String str2 = str. subString (3,6 );
Str = str1.toLowerCase () + str2.toUpperCase ();
If it is an arbitrary string, it needs to be converted into a character array using string. tochararray (). Then compare the data according to the ascII value.
Then convert according to the rule!