offline version v3


74 of 264 menu

String.fromCharCode method

The String.fromCharCode method converts the specified UTF-16 code units to a string.

Syntax

String.fromCharCode(UTF-16 code, UTF-16 code...);

Example

Let's form a string by specifying the UTF-16 code units in the parameters:

let str = String.fromCharCode(65, 66, 67, 68, 69); console.log(str);

The code execution result:

'ABCDE'

Example

Note that the word String cannot be replaced by any other name. For example, this code will not work:

let myString = 'word'; let str = myString.fromCharCode(65, 66, 67); console.log(str);

The code execution result:

'TypeError: myString.fromCharCode is not a function'

See also

  • the charCodeAt method
    that performs the reverse operation
enru