JavaScript toLocaleUpperCase()
The toLocaleUpperCase()
method is a built-in JavaScript function that converts a string to uppercase while taking into consideration the user's locale. The method returns a new string with all alphabetical characters converted to uppercase, based on the language and regional settings of the user's browser.
Syntax
string.toLocaleUpperCase([locale, options])
The toLocaleUpperCase()
method takes two optional parameters:
locale
(optional) - A string that specifies the language and region to use. Default is the user's browser language and settings.options
(optional) - An object that defines additional formatting options, such as for numeric currency or date/time formats.
Example
let name = 'john doe';
let nameUpperCase = name.toLocaleUpperCase();
console.log(nameUpperCase);
Output
JOHN DOE