🎉 New! Announcing our next generation AI code completions

Read here

How to Use the toLowerCase() method in JavaScript

  • 1 min read
  • November 3, 2020
linkedin twitter facebook reddit
linkedin twitter facebook reddit

JavaScript’s toLowerCase() method takes a string and converts it into a new string consisting of only lowercase letters.

Remember: JavaScript strings are immutable. This method will create a new string in memory, in addition to the old string.

Below is an example of how to use toLowerCase():

const str = 'Hello, I am Mark';
console.log(str.toLowerCase());
// Expected output: hello, i am mark

In the above example, const str had three capitalized letters. After applying the toLowerCase() method, all capital letters are converted to lowercase, as seen in the expected output.

Syntax

The syntax of the toLowerCase() method is as follows:

String.toLowerCase()

Note: this method receives no parameters.

Lowercase letters are not affected, neither are digits nor special characters – these characters will be preserved in their original form. Only upper-case letters in the string will be affected.

Tip: You can use a similar method, toUpperrCase(), to capitalize all of the letters in a string.

 

Related Articles

JavaScript – How to Use setAttribute

JavaScript – Global Variable

JavaScript – Array to String

 

Related Posts

How to Use parseInt() in JavaScript

How to Use parseInt() in JavaScript

The parseInt function parses a string argument and returns an integer. In its most simple form, the function looks like this: const x = ‘8’; console.log(parseInt(x));

How to Use promises in JavaScript

How to Use promises in JavaScript

JavaScript is a synchronous language, yet sometimes asynchronous behavior is required. For example, you may need to use an asynchronous function while waiting for data to

How to use the for…of Statement in JavaScript

How to use the for…of Statement in JavaScript

The for…of statement was introduced in ECMAScript2015 (ES6) and adds a powerful new type of loop to JavaScript. JavaScript offers many different types of loops, each