JavaScript String String.fromCharCode() method
- Previous page endsWith()
- Next page includes()
- Go back one level JavaScript String Referentiemanual
Definition and usage
String.fromCharCode()
The method converts Unicode values to characters.
String.fromCharCode()
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);
let text = String.fromCharCode(72, 69, 76, 76, 79);
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 unicode characters. |
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 number encoding.
Note:As a static method,fromCharCode()
Is a property of the constructor String() and not a method of a string or String object.
charCodeAt()
Is with fromCharCode()
A companion instance method that provides a way to get the encoding of a single character in a string.
Browser support
String.fromCharCode()
Is 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 |
- Previous page endsWith()
- Next page includes()
- Go back one level JavaScript String Referentiemanual