JavaScript | String.prototype.toLocaleUpperCase() Method

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

Syntax:

str.toLocaleUpperCase()
str.toLocaleUpperCase(locale) 
str.toLocaleUpperCase([locale, locale, ...])

Parameters:

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

Returns Value: This method returns a string of uppercase letter.

Exceptions: This method gives two kinds of error, 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.

Below examples illustrate the String.prototype.toLocaleUpperCase() method in JavaScript:

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

const gfg = 'GeeKsForGeekS';
console.log('EN-US: ' + gfg.toLocaleUpperCase('en-US'));
console.log('TR: ' + gfg.toLocaleUpperCase('tr'));
  
const gfg1 = new String("String.prototype.toLocaleUpperCase()");
console.log('Result: ' + gfg1.toLocaleUpperCase());

chevron_right


Output:

"EN-US: GEEKSFORGEEKS"
"TR: GEEKSFORGEEKS"
"Result: STRING.PROTOTYPE.TOLOCALEUPPERCASE()"

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

console.log('ALPHABET'.toLocaleUpperCase());
   
console.log('i\u0307'.toLocaleUpperCase('tr') === 'I');  
console.log('i\u0307'.toLocaleUpperCase('lt-LT') === 'I');
   
let geeks = ['lt', 'LT', 'lt-LT', 'lt-u-co-phonebk', 'lt-x-lietuva'];
console.log('i\u0307'.toLocaleUpperCase(geeks) === 'I'); 

chevron_right


Output:

"ALPHABET"
false
true
true

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

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

full-stack-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.