JavaScript String toLowerCase() function is “used to convert a string to lowercase letters and returns a new string with all characters”. It does not change the original string.
The toLowerCase() method raises TypeError when called on null or undefined.
Syntax
string.toLowerCase()
Parameters
It does not take any arguments.
Return Value
The toLowerCase() method returns the string value converted to lowercase and does not affect the value of the string itself.
Example 1: How to toLowerCase() function in JavaScript
Let’s define a string using single quotes and convert it into lowercase.
let strA = 'Avengers will be a great movie';
console.log(strA.toLocaleLowerCase());
Output
This is how you can convert Strings to lowercase.
Example 2: Converting all characters to lowercase
console.log('AppDividend'.toLocaleLowerCase());
console.log('KrunalLathiya'.toLowerCase());
Output
Example 3: Converting all elements of the array to lowercase
To convert an array of elements to lowercase in Javascript, use the combination of join(), toLowerCase(), and split() methods.
let arr = [
'MILLIE',
'NOAH',
'FINN',
'SADIE'
]
let str = arr.join('~').toLowerCase()
let finArr = str.split('~')
console.log(finArr)
Output
[ 'millie', 'noah', 'finn', 'sadie' ]
In the above code, we have used the join() method, the mixed-case array into a string, lowercase it, then split() the string back into an array.
Browser compatibility
- Chrome version 1 and above
- Edge version 12 and above
- Firefox version 1 and above
- Internet Explorer version 3 and above
- Opera version 3 and above
- Safari version 1 and above

