totn JavaScript

JavaScript: String toLowerCase() method

This JavaScript tutorial explains how to use the string method called toLowerCase() with syntax and examples.

Description

In JavaScript, toLowerCase() is a string method that is used to convert a string to lowercase. Because the toLowerCase() method is a method of the String object, it must be invoked through a particular instance of the String class.

Syntax

In JavaScript, the syntax for the toLowerCase() method is:

string.toLowerCase();

Parameters or Arguments

There are no parameters or arguments for the toLowerCase() method.

Returns

The toLowerCase() method returns a string converted to lowercase.

Note

  • The toLowerCase() method does not change the value of the original string.

Example

Let's take a look at an example of how to use the toLowerCase() method in JavaScript.

For example:

var totn_string = 'TechOnTheNet';

console.log(totn_string.toLowerCase());

In this example, we have declared a variable called totn_string that is assigned the string value of 'TechOnTheNet'. We have then invoked the toLowerCase() method of the totn_string variable to convert the string to lowercase.

We have written the output of the toLowerCase() method to the web browser console log, for demonstration purposes, to show what the toLowerCase() method returns.

The following will be output to the web browser console log:

techonthenet

In this example, the toLowerCase() method converted the string 'TechOnTheNet' to lowercase and returned a string value of 'techonthenet'.