toLowerCase() in JavaScript – How to Convert String to Lowercase
Whenever you use toLowerCase() on a string, the method does the following:
- It converts its calling string to lowercase.
- It returns the new version of the calling string—without changing the original string.
note
A calling string is a string on which you used toLowerCase()
. So, in "Hello, World!".toLowerCase()
, "Hello, World!"
is the calling string.
Syntax of the toLowerCase()
Method
Here is toLowerCase()
's syntax:
callingString.toLowerCase();
The snippet above shows that toLowerCase()
does not accept any argument.
Example 1: Convert CodeSweetly
to Lowercase
"CodeSweetly".toLowerCase();
// The invocation above will return: "codesweetly"
Example 2: Convert a JavaScript String to Lowercase
"FRIDAY, MY FRIEND, WAS BORN ON FRIDAY".toLowerCase();
// The invocation above will return: "friday, my friend, was born on friday"
tip
To convert a string to uppercase, use toUpperCase()
.
Overview
toLowerCase()
returns the lowercase version of its calling string.
If you like this article, please Tweet it.
Thanks for reading!