VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-string-fromcharcode-method/

⇱ JavaScript String fromCharCode() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript String fromCharCode() Method

Last Updated : 16 Jul, 2024

The fromCharCode() method in JavaScript is a static method of the String object. Which is used to create a string from a sequence of Unicode values.

Syntax:

String.fromCharCode(n1, n2, ..., nX)

Parameters:

The method takes the UTF-16 Unicode sequences as its argument. The number of arguments to this method depends upon the number of characters to be joined as a string. The range of the numbers is between 0 and 65535.

Return value:

The return value of this method is a string containing the characters whose UTF-16 codes were passed to the method as arguments.

Example 1: Using JavaScript's String.fromCharCode() Method to Generate a String

The function func() uses String.fromCharCode() to convert Unicode values (71, 70, 71) into characters ('G', 'F', 'G'), generating the string "GFG" which is then logged to the console.


Output
GFG

Example 2: Converting Unicode Point to Character with JavaScript's fromCharCode()

The function func() utilizes String.fromCharCode() to translate the UTF-16 code point 0x12014 into its respective character. Subsequently, the character is printed to the console, showcasing the conversion process.


Output

Supported Browsers: 

Comment