Home > Article > Web Front-end > Summary of js letter case conversion implementation methods_javascript skills
toLocaleUpperCase method
Returns a string in which all alphabetic characters have been converted to uppercase, adapting to the host environment's current locale.
stringVar.tolocaleUpperCase( )
The required stringVar reference is a String object, value or literal.
Description
The toLocaleUpperCase method converts characters in a string while adapting to the current locale of the host environment. In most cases, the result is the same as using the toUpperCase method. However, if the language rules conflict with regular Unicode case mapping, the results will be different.
toLocaleLowerCase method
Returns a string in which all alphabetic characters have been converted to lowercase, taking into account the current locale of the host environment.
stringVar.tolocaleLowerCase( )
The required stringVar reference is a String object, value or literal.
Description
The toLocaleLowerCase method converts characters in a string while adapting to the current locale of the host environment. In most cases, the result is the same as using the toLowerCase method. However, if the language rules conflict with regular Unicode case mapping, the results will be different.
toLowerCase method
Returns a string with the letters in the string converted to lowercase letters.
strVariable.toLowerCase( )
"String Literal".toLowerCase( )
Note
The toLowerCase method will not affect non-alphabetic characters.
The following example demonstrates the effect of the toLowerCase method:
var strVariable = "This is a STRING object";
strVariable = strVariable.toLowerCase( );
The value of strVariable after executing the previous statement is:
this is a string object
toUpperCase method
Returns a string with all letters in the string converted to uppercase letters.
strVariable.toUpperCase( )
"String Literal".toUpperCase( )
Note
The toUpperCase method will not affect non-alphabetic characters.
Example
The following example demonstrates the effect of the toUpperCase method:
var strVariable = "This is a STRING object";
strVariable = strVariable.toUpperCase( );
The value of strVariable after executing the previous statement is:
THIS IS A STRING OBJECT