Open In App

TypeScript String String.fromCodePoint() Method

Last Updated : 29 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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:

  • …codePoints: An array of one or more non-negative integer values that represent Unicode code point values.

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.

Javascript




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.

Javascript




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


Output:

🎶

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads