JavaScript String String.fromCharCode() Method

Definition and usage

String.fromCharCode() The method converts Unicode values to characters.

String.fromCharCode() It is a static method of the String object.

The syntax is always String.fromCharCode().

You cannot use myString.fromCharCode().

Example

How to convert Unicode values to characters:

let char = String.fromCharCode(65);

Try it yourself

let text = String.fromCharCode(72, 69, 76, 76, 79);

Try it yourself

Syntax

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

Parameter

Parameter Description
n1, n2, nX Required. One or more Unicode values to be converted.

Return value

Type Description
String A string representing a unicode character.

Tip:For a list of all Unicode values, please read our complete Unicode reference manual.

Technical details

Return value

A new string containing characters with specified encoding.

Description

This static method provides a way to create a string, in which each character in the string is specified by a separate Unicode encoding number.

Note:As a static method,fromCharCode() It is a property of the constructor String() rather than a string or String object method.

charCodeAt() Is associated with fromCharCode() A配套 used instance method, it provides a way to get the encoding of a single character in a string.

Browser support

String.fromCharCode() It is an ECMAScript1 (ES1) feature.

All browsers fully support ES1 (JavaScript 1997):

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support

Related Pages

JavaScript String

JavaScript String Methods

JavaScript String Search