toLowerCase method
The toLowerCase
method converts
characters of a string to lower case
(makes small letters from capital
letters). In doing so, we get a new
string, while the original string
remains unaffected.
Syntax
string.toLowerCase();
Example
Let's convert all capital letters of a string to small letters:
let str = 'ABCDE';
console.log(str.toLowerCase());
The code execution result:
'abcde'
Example
By combining the toLowerCase
method and the
slice
method, you can set lower case for
individual parts of a string:
let str = 'ABCDE';
let res = str.slice(0, 1) + str.slice(1).toLowerCase();
console.log(res);
The code execution result:
'Abcde'
See also
-
the
toUpperCase
method
that converts a string to uppercase -
the
charAt
method
that returns a character in a string