Skip to content

JavaScript fromCharCode() function | convert Unicode example

  • by

JavaScript fromCharCode is used to convert Unicode values to characters. This method can convert one or more Unicode values. This method returns a string created from the specified sequence of UTF-16 code units.

String.fromCharCode(num1)
#OR
String.fromCharCode(n1, n2, ..., nX)

JavaScript fromCharCode example

Simple example code.

<!DOCTYPE html>
<html>
<body>

  <script>
   let char = String.fromCharCode(65);
   console.log(char);   

   let text = String.fromCharCode(72, 69, 76, 76, 79);       
   console.log(text)          

 </script>

</body>
</html>

Output:

JavaScript fromCharCode function

More Examples

String.fromCharCode(65, 66, 67);   // returns "ABC"
String.fromCharCode(0x2014);       // returns "—"
String.fromCharCode(0x12014);      // also returns "—"; the digit 1 is truncated and ignored
String.fromCharCode(8212);         // also returns "—"; 8212 is the decimal form of 0x2014

Do comment if you have any doubts or suggestions on this JS JavaScript from the Char Code method topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading