JavaScript - toLocaleUpperCase() method

revision:


Category : string

The toLocaleUpperCase() method converts a string to uppercase letters, using current locale. The locale is based on the language settings of the browser. The toLocaleUpperCase() method does not change the original string. It returns the same result as toUpperCase(), except for locales that conflict with the regular Unicode case mappings (such as Turkish).

Syntax :

        string.toLocaleUpperCase()  
    

Parameters: none

Examples:

            <p>toLocaleUpperCase() converts a string to uppercase letters, using current locale:</p>
            <p id="demo"></p>
            <script>
                let text = "Hello World!";
                let result = text.toLocaleUpperCase();
                document.getElementById("demo").innerHTML = result;
            </script>
        

Practical examples

example: using locales and options

code:
                <div>
                    <p id="local-1"></p>
                    <p id="local-2"></p>
                </div>
                <script>
                   let text = "Hello World!";
                   document.getElementById("local-1").innerHTML = "text : " + text;
                   let result = text.toLocaleUpperCase();
                   document.getElementById("local-2").innerHTML = "text to upper case : " + result;
        
                </script>