The fromCharCode
method is defined in the String
class in JS and converts the given sequence of numbers to a string.
String.fromCharCode(...);
...
is a sequence of numbers (e.g., num1, num2, ..., numN
) that specifies the UTF-16 encoding for the string.console.log(String.fromCharCode(0x41, 0x42, 0x43));console.log(String.fromCharCode(97, 98, 99));
In the example above, the first call to fromCharCode
passed 3 arguments in hexadecimal notation that represent A
, B
, and C
characters in UTF-16 encoding. The second call to fromCharCode
passed 3 arguments as integers that represent a
, b
, and c
characters in UTF-16 encoding.
Free Resources