javascript tutorial - [Solved-5 Solutions] Convert JavaScript String to lower case - javascript - java script - javascript array



Problem:

How to Convert JavaScript String to lower case ?

Solution 1:

var lowerCaseName = "Your Name".toLowerCase();
click below button to copy the code. By JavaScript tutorial team

Solution 2:

Use either toLowerCase or toLocaleLowerCase methods of the String object. The difference is that toLocaleLowerCase will take current locale of the user/host into account. As per § 15.5.4.17 of the ECMAScript Language Specification (ECMA-262) , toLocaleLowerCase… …works exactly the same as toLowerCase except that its result is intended to yield the correct result for the host environment’s current locale, rather than a locale-independent result. There will only be a difference in the few cases (such as Turkish) where the rules for that language conflict with the regular Unicode case mappings. Example:

var lower = 'Your Name'.toLowerCase();
click below button to copy the code. By JavaScript tutorial team

Solution 3:

"Foo".toLowerCase();
document.getElementById('myField').value.toLowerCase();

click below button to copy the code. By JavaScript tutorial team

Solution 4:

<script type="text/javascript">
var yourstring = 'Your Name'
var lowercase = yourstring.toLowerCase();
document.write('original string:<b> ' + yourstring + '</b><br>');
document.write('converted sting <b>' + lowercase + '</b>');
</script>

click below button to copy the code. By JavaScript tutorial team

Solution 5:

consuming a plugin, and was confused why I was getting a "extension.tolowercase is not a function" JS error.

 onChange: function(file, extension)
    {
      alert("extension.toLowerCase()=>" + extension.toLowerCase() + "<=");
click below button to copy the code. By JavaScript tutorial team

Which produced the error "extension.toLowerCase is not a function" So we tried this piece of code, which revealed the problem!

alert("(typeof extension)=>" + (typeof extension) + "<=");;
click below button to copy the code. By JavaScript tutorial team

Related Searches to javascript tutorial - Convert JavaScript String to lower case