Four functions for converting javascript letters into uppercase and lowercase letters

Source: Internet
Author: User

The conversion of uppercase and lowercase letters in js mainly uses four js functions:

1. toLocaleUpperCase
2. toUpperCase
3. toLocaleLowerCase
4. toLowerCase

The following is a simple analysis of these four JavaScript Functions that implement case-sensitivity conversion.

1. toLocaleUpperCase

Converts all the letter characters in the string to uppercase and adapts to the current region settings in the host environment.

2. toUpperCase

Converts all letters in a string to uppercase letters.

3. toLocaleLowerCase

Converts all letter characters in the string to lowercase, and takes into account the current region settings of the host environment.

4. toLowerCase

Converts letters in a string to lowercase letters.

The usage of the above four functions is basically the same. The following uses toLowerCase as an example:

Copy codeThe Code is as follows:
Var str = 'www .jb51.net/abc ';
Document. write (str. toLowerCase (); // output www.jb51.net/abc

Or:

Copy codeThe Code is as follows: document. write ('www .jb51.net/ABC'.toLowerCase ());

We can see that toLocaleUpperCase and toUpperCase have the same functions. toLocaleLowerCase and toLowerCase have the same functions. What are their differences?

(1) The toLocaleUpperCase toLocaleLowerCase functions adapt to the current region settings in the host environment when converting characters in the string. In most cases, the result is the same as that obtained by using the toUpperCase toLowerCase function. However, if the language rules conflict with the conventional Unicode case-sensitivity ing method, the results will be different.

(2) The toUpperCase toLowerCase method does not convert non-letter characters in the string.

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.