TypeScript String toLocaleUpperCase() Method
The String.prototype.toLocaleUpperCase() method in TypeScript is used to convert the characters within a string to uppercase while respecting the current locale. This can be useful for handling locale-specific uppercase conversions, which may differ from the default toUpperCase() method.
Syntax:
string.toLocaleUpperCase( )
Parameter: This methods does not accept any parameter.
Return Value: This method returns the string in uppercase with the current locale.
Below examples illustrate the String toLocaleUpperCase() method in TypeScript
Examples of String toLocaleUpperCase() Method
Example 1: Basic Usage of toLocaleUpperCase()
In this example, we will demonstrate the basic usage of the toLocaleUpperCase() method to convert a string to uppercase.
const str: string = "GeeksforGeeks - Best Platform";
const upperStr: string = str.toLocaleUpperCase();
console.log(upperStr);
Output:
GEEKSFORGEEKS - BEST PLATFORM
Example 2: Another Example of Using toLocaleUpperCase()
In this example, we will use the toLocaleUpperCase() method on another string to convert it to uppercase
const str: string = "TypeScript - String toLocaleUpperCase()";
const upperStr: string = str.toLocaleUpperCase();
console.log(upperStr);
Output:
TYPESCRIPT - STRING TOLOCALEUPPERCASE()