Open In App

JavaScript String toLowerCase() Method

The toLowerCase() method in JavaScript converts all the characters in a string to lowercase and returns the resulting string.

Syntax:

str.toLowerCase();

Parameters: This method does not accept any parameter.

Return value: This method returns a new string in which all the upper-case letters are converted to lowercase.

JavaScript String toLowerCase() Method Examples

Example 1: Converting all characters of a string to lowercase

The toLowerCase() method is used to convert all characters in the string 'GEEKSFORGEEKS' to lowercase. The resulting string 'geeksforgeeks' is then logged to the console.

function func() {
    let str = 'GEEKSFORGEEKS';
    let string = str.toLowerCase();
    console.log(string);
}
func(); 

Output
geeksforgeeks

Example 2: Converting elements of array to lowercase

The code uses the map() method to create a new array where each element is converted to lowercase using the toLowerCase() method. The resulting array is ['javascript', 'html', 'css'], which is then logged to the console.

let languages = ['JAVASCRIPT', 'HTML', 'CSS'];

let result = languages.map(lang => lang.toLowerCase());
console.log(result);

Output
[ 'javascript', 'html', 'css' ]

We have a complete list of Javascript string methods, to check those please go through this Javascript String Complete reference article.

Supported Browser:

Article Tags :