Skip to content

JavaScript toLocaleLowerCase() | String method

  • by

JavaScript toLocaleLowerCase() string method is used to convert a string to lowercase based on the current locale. The locale is based on the language settings of the browser.

string.toLocaleLowerCase()

Note: It returns the same result as toLowerCase(), except for locales that conflict with the regular Unicode case mappings (such as Turkish). This method does not change the original string.

JavaScript toLocaleLowerCase()

Simple example code.

<!DOCTYPE html>
<html>
<body>
  <script>
    const city = 'GESÄSS';

    console.log(city.toLocaleLowerCase('en-US'));
    console.log(city.toLocaleLowerCase('TR'));

  </script>
</body>
</html>

Output:

JavaScript toLocaleLowerCase String method

In most cases, toLowerCase() will behave the same as toLocaleLowerCase(), but toLocaleLowerCase() should be used when locale-specific behavior is needed.

let str = "İSTANBUL";
console.log(str.toLowerCase()); // Output: "i̇stanbul" (Incorrect in Turkish)
console.log(str.toLocaleLowerCase('tr-TR')); // Output: "istanbul" (Correct in Turkish)

Use Cases

  • Converting user input to lowercase for case-insensitive comparison.
  • It displays text in a locale-sensitive manner.
  • Ensuring consistent casing for strings in multilingual applications.

By using toLocaleLowerCase(), you can handle strings in a way that respects the linguistic and regional nuances of your users’ languages.

Comment if you have any doubts or suggestions on this JS array method tutorial.

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

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading