Open In App

TypeScript String.fromCharCode() Method

Last Updated : 24 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The fromCharCode() is an inbuilt TypeScript String method. It mainly changes Unicode code points within the Basic Multilingual Plane (BMP) into strings. Although it provides a method for dealing with characters through typing on a keyboard it has restrictions when it comes to characters, outside the BMP.

Syntax:

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

Parameters:

  • codePoints: One or more Unicode code points to be converted into characters.

Return Value:

A string that contains characters whose Unicode points were passed as an argument within the method.

Example 1: In this example here we are creating a string from unicode code point values.

JavaScript
let codeUnits: number[] =
    [
        71, 101, 101, 107, 115, 70,
        111, 114, 71, 101, 101, 107, 115
    ];

let geeksString: string = String
    .fromCharCode(...codeUnits);
console.log(geeksString);

Output:

GeeksForGeeks

Example 2: In this example here we are creating a string from unicode code point values.

JavaScript
let codeUnits: number[] =
    [
        74, 111, 104, 110, 68, 111, 101
    ];

let name: string = 
    String.fromCharCode(...codeUnits);
console.log(name);

Output:

JohnDoe

Next Article

Similar Reads