The syntax of String.fromCodePoint() static-method is:
String.fromCodePoint()
String.fromCodePoint(num1)
String.fromCodePoint(num1, num2)
String.fromCodePoint(num1, num2, /* …, */ numN)
This fromCodePoint() static-method of String returns a string created by using the specified sequence of code points.
Parameter | Optional/Required | Description |
---|---|---|
num1 | required | The first code point value. |
num2 | optional | Additional code point values. |
String.fromCodePoint() returns value of type string
.
In this example,
We call String.fromCodePoint
with the code points 65, 66, and 67 which correspond to the characters 'A', 'B', and 'C' respectively.
console.log(String.fromCodePoint(65, 66, 67));
ABC
In this example,
We call String.fromCodePoint
with various code points including emoji and non-BMP characters.
console.log(String.fromCodePoint(9731, 9733, 9842, 0x2F804));
☃★♲你
In this example,
We call String.fromCodePoint
with the code point 0x1F680 which corresponds to the rocket emoji.
console.log(String.fromCodePoint(0x1F680));
🚀
In this JavaScript tutorial, we learned about fromCodePoint() static-method of String: the syntax and few working examples with output and detailed explanation for each example.