![]() |
VOOZH | about |
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.
String.fromCharCode(n1, n2, ..., nX)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.
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.
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.
—