EN
JavaScript - String fromCharCode() method example
0
points
// ONLINE-RUNNER:browser;
console.log(String.fromCharCode(65)); // A
console.log(String.fromCharCode(66)); // B
console.log(String.fromCharCode(67)); // C
1. Documentation
Syntax |
|
Parameters | number1 , ..., numberN - sequence of integer numbers that are UTF-16 code units (in a range between 0 and 65535 (0xFFFF )) |
Result | This method returns a string of length N (not a String object), consisting of the N specified UTF-16 code units. |
Description | The CharCode() is a static method that returns a string created from the specified sequence of UTF-16 code units. |
2. Practical example
In this example, we use the fromCharCode()
method to return strings consisting of the specified UTF-16 code units.
// ONLINE-RUNNER:browser;
console.log(String.fromCharCode(97, 98, 99)); // abc
console.log(String.fromCharCode(960)); // π
console.log(String.fromCharCode(945)); // α
console.log(String.fromCharCode(946)); // β
Output:
abc
π
α
β