EN
JavaScript - String fromCharCode() method example
0 points
xxxxxxxxxx
1
console.log(String.fromCharCode(65)); // A
2
console.log(String.fromCharCode(66)); // B
3
console.log(String.fromCharCode(67)); // C
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. |
In this example, we use the fromCharCode()
method to return strings consisting of the specified UTF-16 code units.
xxxxxxxxxx
1
console.log(String.fromCharCode(97, 98, 99)); // abc
2
3
console.log(String.fromCharCode(960)); // π
4
console.log(String.fromCharCode(945)); // α
5
console.log(String.fromCharCode(946)); // β
Output:
xxxxxxxxxx
1
abc
2
π
3
α
4
β