Home >>JavaScript String Methods >JavaScript String toUpperCase() Method

JavaScript String toUpperCase() Method

JavaScript String toUpperCase() Method

JavaScript toUpperCase() method is used to convert a given input string to uppercase letters. It converts the entire given string to Upper case. It does not change the original given string. It does not affect the special characters, the digits and the alphabets that are in uppercase.

Syntax:
string.toUpperCase()

Browser Support

Method Chrome Edge Firefox Safari Opera
toUpperCase() Yes Yes Yes Yes Yes
Here is an example of toUpperCase() method:
<html>
<body>
<p>Click the button to see the output.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
  var str = "phptpoint";
  var res = str.toUpperCase();
  document.getElementById("demo").innerHTML = res;
}
</script>
</body>
</html>
Output:

Click the button to see the output.

Example 2:
<html>
<body>
<p>Click the button to see the output.</p>
<button onclick="myFunction1()">Try it</button>
<p id="demo1"></p>
<script>
function myFunction1() {
  var str = "abhimanyu";
  var res = str.toUpperCase();
  document.getElementById("demo1").innerHTML = res;
}
</script>
</body>
</html>
Output:

Click the button to see the output.


No Sidebar ads