/

HTML / CSS / JavaScript Tutorial

JavaScript String method: toUpperCase()

[this page | pdf | back links]

The toUpperCase() method (when applied to a JavaScript string) returns a string that is the original string converted to lower case characters, bearing in mind the language settings of the browser.

 

It has the following syntax (with no parameters):

 

string.toUpperCase()

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,th,tr,td {border: 1px solid black; border-collapse: collapse;}
</style>
</head>
<body>
<table>
<tr>
<th>Example</th>
<th>Resulting value of <code>x</code></th>
</tr>
<tr>
<td><code id="Example"></code></td>
<td><code id="Result"></code></td>
</tr>
</table>

<script>
var q = "aBcD";
document.getElementById("Example").innerHTML =
  'var q = "' + q + '";<br>' +
  'var x = q.toUpperCase();';
document.getElementById("Result").innerHTML =
  q.toUpperCase();
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedJavaScriptMethodStringToUpperCase() {
  var z = "abc"; return !!z.toUpperCase;
}


NAVIGATION LINKS
Contents | Prev | Next | JavaScript String Variables


Desktop view | Switch to Mobile