Home >>JavaScript String Methods >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 | Description |
---|---|
n1, n2, ..., nX | This is a required parameter. It defines one or more Unicode values to be converted. |
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
fromCharCode() | Yes | Yes | Yes | Yes | Yes |
<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>
Click the button to see the Output.
<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>
Click the button to see the Output.