JavaScript toLocaleLowerCase: The Complete Guide

0
79
Javascript String toLocaleLowerCase() Tutorial With Example

Javascript String toLocaleLowerCase() is an inbuilt function that converts a string to lowercase letters, according to the host’s current locale. The toLocaleLowerCase() method returns a calling string value converted to the lower case, according to any locale-specific case mappings.

Javascript toLocaleLowerCase

The locale is based on the language settings of the browser. The toLocaleLowerCase() method returns the same result as the toLowerCase() method. However, for some locales, where language conflict with the regular Unicode case mappings occurs (such as Turkish), the results may vary. Javascript toLocaleLowerCase() method does not change the original string.

Syntax

The syntax of string toLowerCase() function is following.

string.toLocaleLowerCase(locale)

The locale parameter indicates a locale to be used to convert to the lower case according to any locale-specific case mappings. If the multiple locales are given in the Array, the best available locale is used.

The toLocaleLowerCase function returns the String, representing the value of a string converted to lowercase according to the host’s current locale.

See the following example.

// app.js

let dottedData = 'Türkçe';
console.log('EN-US: ' + dottedData.toLocaleLowerCase('en-US'));
console.log('TR: ' + dottedData.toLocaleLowerCase('tr'));

See the following output.

Javascript String toLocaleLowerCase() Tutorial

See other examples.

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

See the following output.

String toLocaleLowerCase()

That’s it for this tutorial.

Related posts

JavaScript toLocaleUpperCase()

JavaScript toUpperCase()

Leave A Reply

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.