Skip to content

JavaScript toLowerCase() | String method

  • by

Use JavaScript toLowerCase() String method to convert a given string into lowercase letters string. This method does not change the original string.

string.toLowerCase()

JavaScript toLowerCase

Simple example code convert JavaScript String to be all lower case.

<!DOCTYPE html>
<html lang="en">
<body>
  <script>
    var s1 = "ALPHABET"
    console.log(s1)
    console.log(s1.toLowerCase())
  </script>
</body>
</html>

Output:

JavaScript toLowerCase String method

Just an example for toLowerCase(), toUpperCase() and a prototype for the not yet available toTitleCase() or toProperCase():

String.prototype.toTitleCase = function() {
  return this.split(' ').map(i => i[0].toUpperCase() + i.substring(1).toLowerCase()).join(' ');
}

String.prototype.toPropperCase = function() {
  return this.toTitleCase();
}

var OriginalCase = 'Your Name';
var lowercase = OriginalCase.toLowerCase();
var upperCase = lowercase.toUpperCase();
var titleCase = upperCase.toTitleCase();

console.log('Original: ' + OriginalCase);
console.log('toLowerCase(): ' + lowercase);
console.log('toUpperCase(): ' + upperCase);
console.log('toTitleCase(): ' + titleCase);

Output:

Original: Your Name
toLowerCase(): your name
toUpperCase(): YOUR NAME
toTitleCase(): Your Name

Do comment if you have any doubts or suggestions on this method examples.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *