Languages
[Edit]
EN

JavaScript - String fromCharCode() method example

0 points
Created by:
Iona
415
// ONLINE-RUNNER:browser;

console.log(String.fromCharCode(65)); // A
console.log(String.fromCharCode(66)); // B
console.log(String.fromCharCode(67)); // C

1. Documentation

Syntax

String.fromCharCode(number1)

String.fromCharCode(number1, number2)

String.fromCharCode(number1, number2, ..., numberN)

Parametersnumber1, ..., numberN - sequence of integer numbers that are UTF-16 code units (in a range between 0 and 65535 (0xFFFF))
ResultThis method returns a string of length N (not a String object), consisting of the N specified UTF-16 code units.
DescriptionThe CharCode() is a static method that returns a string created from the specified sequence of UTF-16 code units.

2. Practical example

In this example, we use the fromCharCode() method to return strings consisting of the specified UTF-16 code units.

// ONLINE-RUNNER:browser;

console.log(String.fromCharCode(97, 98, 99)); // abc

console.log(String.fromCharCode(960)); // π
console.log(String.fromCharCode(945)); // α
console.log(String.fromCharCode(946)); // β

Output:

abc
π
α
β

Alternative titles

  1. JavaScript - String.fromCharCode() documentation with examples
  2. js - String fromCharCode() method documentation with examples
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

JavaScript - String (documentation)

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join