This JavaScript tutorial explains how to use the string method known as fromCodePoint() with syntax and examples.
Description
In JavaScript, fromCodePoint() is a string technique that is used to create a string from a sequence of Unicode code factors (that may additionally no longer be representable in a single UTF-16 code unit). Because the fromCodePoint() technique is a static technique of the String constructor, it ought to be invoked via the String constructor object as a substitute than through the particular occasion of the String class.
Syntax
In JavaScript, the syntax for the fromCodePoint() method is:
String.fromCodePoint(value1, value2, ... value_n);
Parameters or Arguments
value1, value2, … value_n The Unicode code points to convert to characters and then concatenate together into a string.
Returns
The fromCodePoint() method accepts a sequence of Unicode code points, converts these values to characters and concatenates them together in a string. This ensuing string is then back by the fromCodePoint() method.
The fromCodePoint() technique will return RangeError if an invalid code point is provided as a parameter.
Note
The fromCodePoint() technique does no longer change the fee of the original string. You can also use the fromCharCode() method if all of the Unicode values are representable in single UTF-16 code units.
Example
Let’s take a look at an instance of how to use the fromCodePoint() technique in JavaScript.
For example:
console.log(String.fromCodePoint(134071));
In this example, we have invoked the fromCodePoint() static method through the String constructor object.
We have written the output of the fromCodePoint() technique to the internet browser console log, for demonstration purposes, to exhibit what the fromCodePoint() approach returns.
The following will be output to the net browser console log:
Leave a Review