The toLowerCase() method of the String class in JavaScript returns the calling string value converted to lowercase.
The syntax of String.toLowerCase() method is:
toLowerCase()
This toLowerCase() method of String returns the calling string value converted to lowercase.
String.toLowerCase() returns value of type String
.
In JavaScript, the toLowerCase()
method converts a string to lowercase letters.
For example,
str
with the value 'HELLO WORLD'
.toLowerCase()
method to convert the string to lowercase.lowerStr
.lowerStr
to the console using the console.log()
method.const str = 'HELLO WORLD';
const lowerStr = str.toLowerCase();
console.log(lowerStr);
hello world
In JavaScript, the toLowerCase()
method can be used to convert a string with mixed case letters to all lowercase letters.
For example,
str
with the value 'JavaScript'
.toLowerCase()
method to convert the string to lowercase.lowerStr
.lowerStr
to the console using the console.log()
method.const str = 'JavaScript';
const lowerStr = str.toLowerCase();
console.log(lowerStr);
javascript
In JavaScript, the toLowerCase()
method only affects alphabetic characters and leaves numbers and symbols unchanged.
For example,
str
with the value 'Hello 123!'
.toLowerCase()
method to convert the alphabetic characters to lowercase.lowerStr
.lowerStr
to the console using the console.log()
method.const str = 'Hello 123!';
const lowerStr = str.toLowerCase();
console.log(lowerStr);
hello 123!
In this JavaScript tutorial, we learned about toLowerCase() method of String: the syntax and few working examples with output and detailed explanation for each example.