Last Updated : 06 Sep, 2024
The JavaScript toLowerCase() method converts all characters in a string to lowercase, returning a new string without modifying the original.
It's commonly used for case-insensitive comparisons, standardizing text input, or formatting strings by ensuring all characters are in lowercase.
Syntax:str.toLowerCase();Return value:
This method returns a new string in which all the upper-case letters are converted to lowercase.
Example 1: Converting all characters of a string to lowercaseThe toLowerCase() method converts all characters in the string 'GEEKSFORGEEKS' to lowercase. The resulting string 'geeksforgeeks' is then logged to the console.
JavaScript
let str = 'GEEKSFORGEEKS';
// Convert to lowercase
let string = str.toLowerCase();
console.log(string);
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);
[ '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 Browsers:JavaScript String toUpperCase() & toLowerCase() Method
Visit CourseRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4