fromCodePoint() JavaScript Method – How to Convert Unicode Code Point to String
Whenever you invoke fromCodePoint(), the method returns the string representation of its Unicode code point arguments.
Syntax of the fromCodePoint()
Method
fromCodePoint()
accepts one or more arguments. Here is the syntax:
String.fromCodePoint(codepoint1, codepoint2, ..., codepointX)
The codepoint
arguments represent the Unicode codepoints you wish to convert to string.
We use fromCodePoint()
as String.fromCodePoint()
because it is a static method of the default JavaScript String
object rather than a method of an object you created.
Examples
Below are examples of the fromCodePoint()
method.
How to convert one code point argument to a string
String.fromCodePoint(73);
// The invocation above will return: "I"
The snippet above returned the string representation of Unicode code point 73
.
How to convert three code point arguments to string
String.fromCodePoint(73, 32, 128150);
// The invocation above will return: "I 💖"
The snippet above returned the string representation of Unicode code points 73
, 32
, and 128150
.
Express Your Love for Coding!
How to convert sixteen code point arguments to string
String.fromCodePoint(
73,
32,
128150,
32,
67,
111,
100,
101,
83,
119,
101,
101,
116,
108,
121,
33
);
// The invocation above will return:
// "I 💖 CodeSweetly!"
The snippet above returned the string representation of fromCodePoint()
's arguments.
To convert a JavaScript string to a Unicode code point, use codePointAt()
.
Overview
fromCodePoint()
is a string method that converts one or more Unicode code points to their string representation.
Your support matters: Buy me a coffee to support CodeSweetly's mission of simplifying coding concepts.
Tweet this article