Using String toLocaleLowerCase() method to coding in Javascript/JS

This JavaScript tutorial explains how to use the string method known as toLocaleLowerCase() with syntax and examples.


In JavaScript, toLocaleLowerCase() is a string method that is used to convert a string to lowercase based totally on locale. Because the toLocaleLowerCase() method is a technique of the String object, it need to be invoked through a unique instance of the String class.


In JavaScript, the syntax for the toLocaleLowerCase() technique is:


Parameters or Arguments

locale Optional. It is a BCP forty seven language tag or an array of such tags. A BCP 47 language tag defines a language that might also comprise a important language code as nicely as an extension. If this parameter is now not provided, the toLocaleLowerCase() method will use the host environment’s contemporary locale.


The toLocaleLowerCase() method returns a string transformed to lowercase the usage of a precise locale.


The toLocaleLowerCase() technique does now not trade the cost of the unique string.


Let’s take a look at an example of how to use the toLocaleLowerCase() method in JavaScript.

For example:

var totn_string = 'TechOnTheNet';


In this example, we have declared a variable referred to as totn_string that is assigned the string value of ‘TechOnTheNet’. We have then invoked the toLocaleLowerCase() method of the totn_string variable to convert the string to lowercase.

We have written the output of the toLocaleLowerCase() method to the net browser console log, for demonstration purposes, to show what the toLocaleLowerCase() method returns.

The following will be output to the net browser console log:


In this example, the toLocaleLowerCase() approach used the host’s cutting-edge locale and transformed the string ‘TechOnTheNet’ to lowercase and again a string value of ‘techonthenet’.

Specifying a Locale Parameter

Instead of the usage of the host’s present day locale, you can also specify a BCP 47 language tag for the locale parameter that will be used to convert the string to lowercase.

For example:

var totn_string = 'CAFÉ';


The following will be output to the net browser console log:


In this example, the toLocaleLowerCase() method used a locale parameter of ‘en-US’ to convert the string to lowercase using US English. The toLocaleLowerCase() technique back a string cost of ‘café’.