String.fromCharCode()
Creates a string from a sequence of UTF-16 code units.
Syntax
String.fromCharCode(...codeUnits) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
codeUnits | number | No | One or more numbers between 0 and 65535 representing UTF-16 code units. |
Returns
string — A string created from the given code units.
Examples
console.log(String.fromCharCode(72, 105));
Output
Hi
console.log(String.fromCharCode(65));
Output
A
Notes
Works with 16-bit code units, so characters above U+FFFF require surrogate
pairs. Use `String.fromCodePoint` for full code points. It is a static method
on String, not an instance method.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 1.0 |
| firefox | 1.0 |
| safari | 1.0 |
| edge | 12 |
| node | 0.10 |