Javascript String ToLowerCase

JavaScript string ToLowerCase; Through this tutorial, i am going to show you how to convert string characters into lowercase using this method using javaScript ToLowerCase method.

Convert String to Lowercase In javaScript

JavaScript str.toLowerCase() method converts the characters of a string into lower case characters.

The following syntax represents the string.toLowerCase() method:


Explanation about the syntax;

  • a string which you want to convert into lowercase.
  • toLowerCase() is method, which is used to convert string characters into lowercase.

Let’s take a look at the example:

let str = 'A Quick Javascript Tutorial';
console.log(str.toLowerCase()); // output: a quick javascript tutorial

In this example, you can see all the uppercase string characters converted into lowercase with the help of javascript toLowerCase() method.

How to Convert Array to toLowerCase

Let’s take an example to convert array string to lowercase in javascript; as shown below:

let arr = [
let str = arr.join('~').toLowerCase()
let newArr = str.split('~')
console.log(newArr) //Output:  ["javascript", "php", "mysql", "sql"]

TypeError: Cannot read property ‘toLowerCase’ of undefined

In case, you pass the undefined string into toLowerCase() method and then you will get some error. The error looks like this: TypeError: Cannot read property ‘toLowerCase’ of undefined.

The following example:

let str = undefined
let res = str.toLowerCase();
console.log(res) // TypeError: Cannot read property ‘toLowerCase’ of undefined.

Recommended JavaScript Tutorials

Leave a Comment