Note that, this method does not affect any of the special characters, digits, and string characters that are already in lowercase.
The following syntax represents the string.toLowerCase() method:
- 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:
How to convert a string to lowercase which is stored in an array?. You can see the following example:
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.