Example of getting started with the toLowerCase method of a JavaScript string object (used to convert letters to lowercase) and javascript to lowercase

Source: Internet
Author: User

Example of getting started with the toLowerCase method of a JavaScript string object (used to convert letters to lowercase) and javascript to lowercase

JavaScript toLowerCase Method

The toLowerCase method is used to convert a (English) string to lowercase and return the converted string. The syntax is as follows:
Copy codeThe Code is as follows:
Str_object.toLowerCase ()

ToLowerCase method example

Copy codeThe Code is as follows:
<Script language = "JavaScript">
Var str = "AaBbCc ";
Alert (str. toLowerCase ());
</Script>

Run this example. The output in the pop-up prompt box is aabbcc.

ToLocaleLowerCase Method

The toLocaleLowerCase method is basically the same as the toLowerCase method. toLocaleLowerCase converts the string to lowercase in a local way. Only a few languages (such as Turkish) have local-specific case ing.


In javascript, the string object uses tolowercase () to convert the string to lowercase. The string itself will change, or it will remain the same as java.

Same as java

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 );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.