JS in the implementation of the letter case conversion is mainly used in four JS functions:
1.toLocaleUpperCase
2.toUpperCase
3.toLocaleLowerCase
4.toLowerCase
The following is a simple analysis of these four JS functions for case conversion.
1.toLocaleUpperCase
Converts all alphabetic characters in a string to uppercase and adapts to the current locale of the host environment.
2.toUpperCase
Converts all letters in a string to uppercase letters.
3.toLocaleLowerCase
Converts all alphabetic characters of a string to lowercase, taking into account the current locale 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 is illustrated with toLowerCase examples:
Copy Code code as follows:
var str= ' Www.jb51.net/ABC ';
document.write (Str.tolowercase ());//Will output WWW.JB51.NET/ABC
Or:
Copy Code code as follows:
document.write (' Www.jb51.net/ABC '. toLowerCase ());
We can see that tolocaleuppercase and toUpperCase functions are the same, tolocalelowercase and tolowercase are the same function, then what is the difference between them?
(1) toLocaleUpperCase tolocalelowercase These two functions, when converting characters in a string, are adapted to the host environment's current locale. In most cases, the result is the same as the result of the use of toUpperCase tolowercase the two functions. However, if the language rules conflict with the normal Unicode case mapping, the results will be different.
(2) The toUpperCase toLowerCase method does not convert non-alphanumeric characters in strings.