toLowerCase() JavaScript

Learn via video course
FREE
View all courses
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
Topics Covered

Overview

The toLowerCase() is a built-in method in javascript which is used for the conversion of uppercase characters into lowercase characters in a string. This method does not affect any special characters or digits in the string, and after the conversion, the original value of the string remains unaffected.

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Syntax of String toLowerCase() in JavaScript

The syntax of toLowerCase Javascript method is given below :

Here, the toLowerCase() is a method to convert the string into lowercase, whereas str is a variable containing a string to be converted to lowercase.

Parameters of String toLowerCase() in JavaScript

As you are probably aware, the toLowerCase() is a method, and it could have parameters, but there are no arguments or parameters received by toLowerCase() method.

Return Value of String toLowerCase() in JavaScript

Return Type: string

The toLowerCase() javascript method returns the new string that is a lowercase string with all the uppercase letters converted to lowercase.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Exceptions of String toLowerCase() in JavaScript

  • If we initialize the string as undefined or null, you will get a TypeError. Let's take one example for the same.

Code:

Output:

What is String toLowerCase() in JavaScript

The toLowerCase() is a built-in method in JavaScript, this method is used for the conversion of any string into lowercase. This method keeps the special characters, numbers, and alphabets already in lowercase as unaffected after the conversion. This method does not change the original value of the string. Taking a look at the syntax below, the value of str will be the same after the conversion, whereas the whole str.toLowerCase() returns the value of the converted string, which can be stored inside another variable.

Examples of String toLowerCase() in JavaScript

Let's take some examples to demonstrate how toLowerCase() works.

Example 1: Convert a simple string into lowercase.

Code:

Output:

In the above code, the str variable stores the string initially. The str.toLowerCase() returns the string with all the letters converted to lowercase, and the string is stored inside the variable convert. This conversion does not affect the variable str, and its initial value remains the same.

Since the str value remains the same, let's understand how toLowerCase() method works internally.

  1. In the internal process, a character array is created of strings, and then the characters are compared and converted to lowercase.
  2. After an array containing all of the desired lowercase characters is constructed, it is converted to a string, and the new string is created.
  3. Therefore, in this process, the string object passed to this method will not be altered. Instead, it creates and returns an entirely new string object.

Let's take a look at some different types of examples using toLowerCase().

Example 2: String with special characters and numbers. Code:

Output:

In the above example, we have a string that contains the special characters along with the alphabet. After conversion, the lowercase characters, numbers, and the special characters remain preserved in their original form as the toLowerCase() does not affect them.

Conclusion

We can conclude for the toLowerCase javascript method that :

  • This method converts the uppercase alphabets into lowercase alphabets of the string without affecting the special characters, numbers, and the alphabets which are already in lowercase.
  • This method does not affect the initial variable or does not change the original value of the string.
  • The method internally converts the string into a character array for conversion, and later, it is again converted to a string which it returns in the end.
  • It does not receive any argument and returns a newly formed string.
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more