Home »
        JavaScript
    
    String fromCharCode() Method with Example in JavaScript
    
    
    
    
        JavaScript String fromCharCode() Method: Here, we are going to learn about the fromCharCode() function in JavaScript with Example.
        
            Submitted by IncludeHelp, on February 07, 2019
        
    
    
    String fromCharCode() Method
    fromCharCode() Method is a string method in JavaScript, it is used to get the character from the given Unicode(s). By using this function, we can get the characters from the given Unicode’s. Here, we can pass multiple numbers to get their corresponding characters.
    Note: We can also provide the number in octal (following by 0) and hexadecimal format (following by 0x).
        
Syntax
            
    String.fromCharCode(number1, number2, number2, ...);
    
    
    Parameters
    It accepts one or more numbers (Unicode), and returns the characters of them.
Sample Input/Output
    
    Function call: 
    String.fromCharCode(65);
    Output:
    "A"
    Function call: 
    String.fromCharCode(65, 66);
    Output:
    "AB"
Example
<html>
<head>
<title>JavaScipt Example</title>
</head>
<body>
<script>
	//passing values in decimal 
	document.write(String.fromCharCode(65) + "<br>");
	document.write(String.fromCharCode(65, 66) + "<br>");
	document.write(String.fromCharCode(65, 66, 67) + "<br>");
	document.write(String.fromCharCode(72, 69, 76, 76, 79) + "<br>");
	//passing values in octal
	document.write(String.fromCharCode(0101) + "<br>");
	document.write(String.fromCharCode(0101, 0102) + "<br>");
	document.write(String.fromCharCode(0101, 0102, 0103) + "<br>");
	document.write(String.fromCharCode(0110, 0105, 0114, 0114, 0117) + "<br>");	
	
	//passing values in hexadecimal 
	document.write(String.fromCharCode(0x41) + "<br>");
	document.write(String.fromCharCode(0x41, 0x42) + "<br>");
	document.write(String.fromCharCode(0x41, 0x42, 0x43) + "<br>");
	document.write(String.fromCharCode(0x48, 0x45, 0x4C, 0x4C, 0x4F) + "<br>");	
</script>
</body>
</html>
Output
A
AB
ABC
HELLO
A
AB
ABC
HELLO
A
AB
ABC
HELLO
	JavaScript String Object Methods »
	
	
    
    
    
    
    
  
    Advertisement
    
    
    
  
  
    Advertisement