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.