JavaScript method fromCharCode()

Ads
 

JavaScript method fromCharCode()

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.

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.

JavaScript method fromCharCode()

     

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:

Download Source Code

     

Ads

Ads