Open In App

JavaScript String toLowerCase() Method

Improve
Improve
Like Article
Like
Save
Share
Report

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.

JavaScript
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.

JavaScript
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:

  • Chrome 1 and above
  • Edge 12 and above
  • Firefox 1 and above
  • Internet Explorer 3 and above
  • Opera 3 and above
  • Safari 1 and above

Last Updated : 14 Mar, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads