JavaScript toLowerCase Function With Examples

JavaScript toLowerCase Function is used to convert strings to lowercase letters.

The JavaScript toLowerCase method does not modify the actual string. It just converted the complete statement of string to lowercase letters.

Introduction

JavaScript is a very essential part of web development. Inside JavaScript there are many types of methods available, in this article, we also discuss one of the basic JS methods toLowerCase() which is mainly used to convert string uppercase to lowercase letters.

Syntax of JS toLowerCase

Note: No parameters are needed.

Basic Example: How to use toLowerCase in JavaScript

When We Can Use JavaScript toLowerCase

  1. When you create any login or sign-up form with an email field, at the time of taking the email to store it on DB, you can use JavaScript toLowerCase() method to lowercase the letters on DB.
  2. Also, JS toLowerCase method is used with textarea data and any editor data to convert all the letters to lowercase then store it on our backend database.

Example to Lowercase The Email

Output:

Example JavaScript toLowerCase

Also Read: Detailed Article About JavaScript else if Statement

Example to Check Special Characters with JS toLowerCase Method

According to the below example, we can see JS toLowerCase method does not affect the special characters.

Output:

Example to Check Special Characters with JS toLowerCase Method

Also Read: Trigger Submit Button By Pressing Enter Key in JavaScript And JQuery

JavaScript toLowerCase Is Not a Function

As we all know JS toLowerCase method only works for strings not for numbers.

When anyone uses the toLowerCase function with the number then it will throw this error “JavaScript toLowerCase Is Not a Function“.

If you want to do that check the below example,

JavaScript toLowerCase Is Not a Function

In the above example first, we convert the number to string then we use the JS lowercase method. So it returns an output not an error.

Conclusion

In this complete article, we discussed many types of examples related to the toLowerCase function and also discuss when we can use it and how we can use it.

Please let me know if you are facing any issues at the time of use.

You can test all the examples here, JSFiddle – Code Playground.

Happy Coding..!

Was this article helpful?
YesNo

By Bikash

My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP.

One thought on “JavaScript toLowerCase Function With Examples”

Leave a Reply

Your email address will not be published. Required fields are marked *