Tutorial Gateway

  • C Programming
  • Java
  • R
  • SQL
  • MySQL
  • Python
  • BI Tools
    • Informatica
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • QlikView
  • About
    • About Us
    • Contact Us

JavaScript FromCharCode

24-11-2015 by suresh Leave a Comment

FromCharCode()

The JavaScript FromCharCode function is one of the JavaScript String Function which is used to convert the Unicode values to string values (based on ASCII Table). In this article we will show you, How to write FromCharCode() method in JavaScript Programming language with example.

JavaScript FromCharCode Syntax

The basic syntax of the FromCharCode function in JavaScript Programming language is as shown below:

1
String.fromCharCode(ASCII_Value)

NOTE: The FromCharCode() function in JavaScript is a static function of string objects so, we have to use String Object while calling this function. For example, String.fromCharCode(109)

JavaScript FromCharCode Example

The following set of examples will help you understand the FromCharCode() function in JavaScript Programming language.

JAVASCRIPT CODE

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<html>
<head>
    <title> JavaScript FromCharCode() </title>
</head>
<body>
    <h1> JavaScript FromCharCode </h1>
    <p id= "Content1">Content 1</p>
    <p id= "Content2">Content 2</p>
    <p id= "Content3">Content 3</p>
    <p id= "Content4">Content 3</p>
<script>
  var Str1 = String.fromCharCode(84,117,116,111,114,105,97,108);
  var Str2 = String.fromCharCode(71,97,116,101,119,97,121);
  
  document.getElementById("Content1").innerHTML =  String.fromCharCode(65);
  document.getElementById("Content2").innerHTML =  String.fromCharCode(97);
  document.getElementById("Content3").innerHTML =  Str1;
  document.getElementById("Content4").innerHTML =  Str2;
 
</script>
</body>
</html>

OUTPUT

JavaScript FromChatCode Function

ANALYSIS

Within the Script tag, Following statement will find the character at ASCII value 65.

1
document.getElementById("Content1").innerHTML =  String.fromCharCode(65);

Following statement will find the character at ASCII value 97.

1
document.getElementById("Content2").innerHTML =  String.fromCharCode(97);

Following statements will create a word by grouping multiple ASCII numbers in one function

1
2
var Str1 = String.fromCharCode(84,117,116,111,114,105,97,108);
var Str2 = String.fromCharCode(71,97,116,101,119,97,121);

Below statements will help us to print the output

1
2
  document.getElementById("Content3").innerHTML =  Str1;
  document.getElementById("Content4").innerHTML =  Str2;

Thank You for Visiting Our Blog

Placed Under: JavaScript

Share your Feedback, or Code!! Cancel reply

Trending

  • SQL Server Tutorial
  • SQL Server Integration Services (SSIS)
  • SQL Server Reporting Services (SSRS)
  • Home
  • Tableau
  • C Program to Calculate the Sum and Average of n Number
  • Simple Python Program

Stay in Touch!

Sign Up to receive Email updates on Latest Tutorials

  • Blogger
  • C Programs
  • Java Programs
  • SQL
  • SSIS
  • SSRS
  • Tableau
  • JavaScript

Copyright © 2018 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy