Skip to content

JavaScript toLocaleUpperCase() | String method

  • by

JavaScript toLocaleUpperCase() string method is used to convert the string to an uppercase letter based on the host’s current locale. The locale is based on the language settings of the browser.

string.toLocaleUpperCase()

This method does not change the original string and returns the same result as toUpperCase() method.

JavaScript toLocaleUpperCase()

Simple example code.

<!DOCTYPE html>
<html>
<body>
  <script>
    const city = 'istanbul';

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

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

Output:

JavaScript toLocaleUpperCase String method

More examples

'alphabet'.toLocaleUpperCase(); // 'ALPHABET'

'Gesäß'.toLocaleUpperCase(); // 'GESÄSS'

'i\u0307'.toLocaleUpperCase('lt-LT'); // 'I'

let locales = ['lt', 'LT', 'lt-LT', 'lt-u-co-phonebk', 'lt-x-lietuva'];
'i\u0307'.toLocaleUpperCase(locales); // 'I'

You can also specify a locale (or an array of locales) to ensure the string is converted according to the rules of that locale. Here’s an example:

let str = "i̇stanbul"; // Turkish locale example
let upperStr = str.toLocaleUpperCase('tr-TR');
console.log(upperStr); // Output: "İSTANBUL" (with dotted İ)

Do comment if you have any doubts or suggestions on this JS string 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