Open In App

TypeScript String String.fromCodePoint() Method

The fromCodePoint() is an inbuilt TypeScript String method. It is mainly used to get the string value of any given Unicode point value. This method is really helpful when you want to handle characters that are not readily available through keyboard input.

Syntax:

String.fromCodePoint(...codePoints: number[]): string

Parameters:

Return Value:

Returns a string that is created from given Unicode points.



Example 1: Here we are going to create a grinning face emoji by unicode point.




const e: number = 0x1F60A;
const emoji: string = String
    .fromCodePoint(e);
console.log(emoji);

Output:



😊

Example 2: Here we are going to create a grinning musical note emoji by Unicode point.




const f: number = 0x1F3B6;
const musicalNote: string = String
    .fromCodePoint(f);
console.log(musicalNote);

Output:

🎶
Article Tags :