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 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, where 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() and not a method of a string or String object.

charCodeAt() It is associated with fromCharCode() An instance method used with the string, which provides a way to get the encoding of a single character in the 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
Unterstützung Unterstützung Unterstützung Unterstützung Unterstützung Unterstützung

Verwandte Seiten

JavaScript-String

JavaScript-String-Methode

JavaScript-String-Suche