The source code for this blog is available on GitHub.

Blog.

JavaScript String toLowerCase()

Cover Image for JavaScript String toLowerCase()
Srinivas Ramakrishna
Srinivas Ramakrishna
Posted underJavaScript

In this tutorial, we will learn about the JavaScript String toLowerCase() method with examples.

The JavaScript String toLowerCase() method converts the string into lowercase and returns a new string.

toLowerCase() Example

// JavaScript Program to illustrate toLowerCase() function

const text = "WELCOME TO JAVASCRIPT WORLD";

// convert uppercase to lowercase
const lowerCaseText = text.toLowerCase();
console.log(lowerCaseText)


// Output: welcome to javascript world

toLowerCase() Syntax

The syntax of the JavaScript toLowerCase() method is as follows.

str.toLowerCase()

Here the str is the string or the string variable.

toLowerCase() Parameter

The JavaScript toLowerCase() method does not accept any arguments.

toLowerCase() Return Value

The toLowerCase() method converts the given string into lowercase and returns it as a new string. The original string value remains unaffected.

Note: The toLowerCase() method raises TypeError when called on null or undefined.

Example: JavaScript Convert string from uppercase to lowercase

// JavaScript Program to illustrate toLowerCase() function

const text1 = "HELLO WORLD";
const text2 = "JAvAsCRIpt iS FuN";

console.log(text1.toLowerCase());
console.log(text2.toLowerCase());

Output

hello world
javascript is fun

More Stories

Cover Image for [Solved] Error: Cannot find module ‘node:events’

[Solved] Error: Cannot find module ‘node:events’

If you are trying to use the Discord.js to develop any custom application and if you are not using latest version of Node.js you will get an Error: Cannot find…
Cover Image for JavaScript String toUpperCase()

JavaScript String toUpperCase()

In this tutorial, we will learn about the JavaScript String toUpperCase() method with examples. The JavaScript String toUpperCase() method converts the string into uppercase and returns a new string. toUpperCase()…