There are 4 methods involved in string case conversion in ECMAScript: toLowerCase (), toLocaleLowerCase (), toUpperCase (), and toLocaleUpperCase ().
Among them, toLowerCase () and toUpperCase () are two classical methods, drawing on the same name method from Java.lang.String. The toLocaleLowerCase () and toLocaleUpperCase () methods are for specific areas of implementation.
For some regions, a region-specific approach results in the same result as a common method, but a few languages (such as the Turkish language) apply special rules for Unicode case conversions, and the region-specific approach must be used to ensure that the correct conversion is implemented. Here are a few examples:
var stringvalue = "Hello World";
Alert (Stringvalue.tolocaleuppercase ()); "HELLO World"
Alert (Stringvalue.touppercase ()); "HELLO World"
Alert (Stringvalue.tolocalelowercase ()); "Hello World"
Alert (Stringvalue.tolowercase ()); "Hello World" 123456
Code laycode-v1.1
The above code calls toLocaleUpperCase () and toUpperCase () all return "Hello World", just like calling toLocaleLowerCase () and toLowerCase () return "Hello World" The same. In general, it is more prudent to use a region-specific approach without knowing that your code will run in that language environment.
The difference between toLowerCase and tolocalelowercase