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

JavaScript String fromCharCode() Method

JavaScript String fromCharCode() Method

JavaScript fromCharCode() method is used to convert the Unicode values into characters. It is a static method of the String object so the syntax will remain always same.

Syntax:
String.fromCharCode(n1, n2, ..., nX)

Parameter Values

Parameter Description
n1, n2, ..., nX This is a required parameter. It defines one or more Unicode values to be converted.

Browser Support

Method Chrome Edge Firefox Safari Opera
fromCharCode() Yes Yes Yes Yes Yes
Here is an example of fromCharCode() 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 res = String.fromCharCode(75);
  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="myFunction()">Try It</button>
<p id="demo"></p>
<script>
function myFunction() {
  var res = String.fromCharCode(27, 32, 35, 72, 52);
  document.getElementById("demo").innerHTML = res;
}
</script>
</body>
</html>
Output:

Click the button to see the Output.


No Sidebar ads