Javascript String toLowerCase()

The JavaScript String toLowerCase() method returns the string converted to lowercase.

The syntax of the toLowerCase() method is:

str.toLowerCase()

Here, str is a string.


toLowerCase() Parameters

The toLowerCase() method does not take in any parameters.


Return value from toLowerCase()

  • Returns a new string representing the calling string converted to lowercase.

Notes:

  • The toLowerCase() method raises TypeError when called on null or undefined.
  • The toLowerCase() method does not change the original string.

Example: Using toLowerCase() method

let str = "Hello World!";
let sentence = "Java is to JavaScript what Car is to Carpet.";

let lowercase_str = str.toLowerCase();
console.log(lowercase_str); // hello world!

let lowercase = sentence.toLowerCase();
console.log(lowercase); // java is to javascript what car is to carpet.

Output

hello world!
java is to javascript what car is to carpet.

Recommended Reading: JavaScript String toUpperCase()