Convert String to Lowercase JavaScript

Convert String to Lowercase JavaScript | When dealing with a string in JavaScript, one might like to modify the case of the string. If you’re making a sign-up form that gathers a user’s email address, for example, you might want the email address to be all lowercase.

The toUpperCase() and toLowerCase() JavaScript methods help with this. You can change a string to all-uppercase or all-lowercase using these methods.

In this lesson, we’ll look at how to use the toLowerCase() String functions in JavaScript. Strings are a JavaScript data type for storing text. Letters, symbols, numerals, and white spaces can all be used in strings. The string data type is significant because it enables programmers to transmit text-based data via a computer program.

Strings can be defined in JavaScript with single quotes (''), double quotes (""), or backticks (``). Single quotes and double quotes can also be used interchangeably, but you should use them consistently across a code.

The following is the procedure’s general syntax:- String.toLowerCase();
There are no parameters in the toLowerCase() function.

In JavaScript, strings are immutable or irreversible. The toLowerCase() method returns the result of converting the provided string into a new one that only contains lowercase letters. It implies that the old, initial string is unaffected in any way.

String to Lowercase JavaScript Example

Let’s have a look at a few examples to understand how to convert string to lowercase JavaScript. 

Example 1:

let greet = 'Hello, Welcome to Know Program';


hello, welcome to know program

The only capital letter is used in the greeting string, which is then transformed to lowercase.

The toLowerCase() method has no effect on lowercase letters; only uppercase letters are affected. These letters have been preserved in their original state.

In the example below, the string is entirely composed of capital letters. The toLowerCase() method is then used to convert them all to lowercase.

Example 2:

let greet = 'HELLO WORLD!';


hello world!

This brings us to the end of this article. We saw a very easy and efficient method to change or convert string to lowercase JavaScript.

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!

Leave a Comment

Your email address will not be published.