The String.prototype.toLocaleLowerCase() method in TypeScript is used to convert the characters within a string to lowercase while respecting the current locale. This method is useful when you need to ensure that the conversion to lowercase is sensitive to locale-specific rules.
Syntax:
string.toLocaleLowerCase( ) Parameter: This methods does not accepts any parameter.
Return Value: This method returns the string in lowercase with the current locale.
Below examples illustrate the String toLocaleLowerCase() method in TypeScript
Examples of String toLocaleLowerCase() Method
Example 1: Basic Usage of toLocaleLowerCase()
In this example, we will demonstrate the basic usage of the toLocaleLowerCase() method to convert a string to lowercase.
const str: string = "GeeksforGeeks - Best Platform";
const lowerStr: string = str.toLocaleLowerCase();
console.log(lowerStr);
Output:
geeksforgeeks - best platform
Example 2: Another Example of Using toLocaleLowerCase()
In this example, we will use the toLocaleLowerCase() method on another string to convert it to lowercase.
const str: string = "TypeScript - String toLocaleLowerCase()";
const lowerStr: string = str.toLocaleLowerCase();
console.log(lowerStr);
Output:
typescript - string tolocalelowercase()