This section illustrates you the use of JavaScript method fromCharCode(). The fromCharCode() method returns a readable string from the specified sequence of Unicode character values.
Its Syntax is:
| String.fromCharCode(n1, n2, ..., nn) |
The argument 'n' is the series of Unicode character values. This method is a static method of String and cannot be used as a method of a String object that you have created. In the given example, we have used this method which translate the specified sequence of Unicode character values into the text. Here, we have specified the Unicode values of English alphabets and the Unicode values of HELLOWORLD.
Here is the code:
| <html> <h2>Use of method fromCharCode()</h2> <script type="text/javascript"> document.write(String.fromCharCode(72,69,76,76,79,87,79,82,76,68)); document.write("<br />"); document.write("English Alphabets:") document.write(String.fromCharCode(65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,90)); </script> </html> |
Output will be displayed as:

From the above output, you will see that the Unicode values that you have specified are converted into the texts:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: JavaScript method fromCharCode()
Post your Comment