Thursday, July 4, 2024
HomeLanguagesJavascriptJavaScript String toLocaleLowerCase() Method

JavaScript String toLocaleLowerCase() Method

The String.prototype.toLocaleLowerCase() method in JavaScript is a Standard built-in object which returns the calling string value converted to a lowercase letter on the basis of the host’s current locale. 

Syntax:

str.toLocaleLowerCase()
str.toLocaleLowerCase(locale)

Parameters:

  • locale: It is an optional parameter and it indicates the locale to be used to convert to lowercase according to any locale-specific case mappings.

Returns Value:

This method returns a string of lowercase letters. 

Exceptions:

This method gives two kinds of errors, which are as follows:

  • RangeError: If the locale argument isn’t a valid language tag.
  • TypeError: If an array element isn’t of type string.

The below examples illustrate the String.prototype.toLocaleLowerCase() method in JavaScript: 

Example 1: In this example, we will convert the uppercase string to a lowercase string and console it using the String.prototype.toLocaleLowerCase() method in JavaScript.

javascript




// Input string
let gfg = 'GeeKsForGeekS';
 
// Output with lowercase method
console.log('EN-US: ' + gfg.toLocaleLowerCase('en-US'));
console.log('TR: ' + gfg.toLocaleLowerCase('tr'));
 
// New input string
let gfg1 = new String("String.prototype.toLocaleLowerCase()");
 
// Display output
console.log('Result: ' + gfg1.toLocaleLowerCase());


Output

EN-US: neveropen
TR: neveropen
Result: string.prototype.tolocalelowercase()

Example 2: In this example, we will convert the uppercase string to a lowercase string and console it using the String.prototype.toLocaleLowerCase() method in JavaScript.

javascript




console.log('ALPHABET'.toLocaleLowerCase());
     
console.log('\u0130'.toLocaleLowerCase('tr') === 'i');
console.log('\u0130'.toLocaleLowerCase('en-US') === 'i');
     
let neveropen = ['tr', 'TR', 'tr-TR', 'tr-u-co-search', 'tr-x-turkish'];
console.log('\u0130'.toLocaleLowerCase(neveropen) === 'i');


Output

alphabet
true
false
true

We have a complete list of Javascript String methods, to check those please go through this JavaScript String Complete Reference article.

Supported Browsers: The browsers supported by the String.prototype.toLocaleLowerCase() method are listed below:

  • Google Chrome
  • Firefox
  • IE
  • Opera
  • Safari
  • Edge

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Ted Musemwa
As a software developer I’m interested in the intersection of computational thinking and design thinking when solving human problems. As a professional I am guided by the principles of experiential learning; experience, reflect, conceptualise and experiment.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments