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
Section titled “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.
Examples
Section titled “Examples”Below are examples of the fromCodePoint()
method.
Convert one code point argument to a string
Section titled “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
.
Convert three code point arguments to string
Section titled “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
.
Convert sixteen code point arguments to string
Section titled “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.