Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

string
java

What is the string fromCodePoint() method in JavaScript?

Sarvech Qadir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The method fromCodePoint() takes a sequence of code pointsUnicode assigns an integer value to each character, known as a code point. and returns the string that corresponds to those code points.

Syntax

String.fromCodePoint(num1, ..., numN)

Parameters

Two or more integer parameters, where each num represents a code point.

num1, ..., numN - A sequence of code points.

Return value

The method returns a string that corresponds to these code points. Note that a string is returned and not a String object.

fromCodePoint() method throws a RangeErrorif an invalid Unicode code point is provided as an argument.

Code

Let’s look at a code example. We can see that the ASCII value of 'A' is 65, 'B' is 66, etc. The code points represent these ASCII values.

let str = String.fromCodePoint(65, 66, 67, 68, 69);
console.log(str); // ABCDE
let str1 = String.fromCodePoint(65, 89, 90, 78, 79);
console.log(str1); // AYZNO

RELATED TAGS

string
java

CONTRIBUTOR

Sarvech Qadir
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring