JavaScript fromCharCode() method explained

The JavaScript fromCharCode() method is a static method of the JavaScript String object that allows you to convert a Unicode number.

A Unicode number is a unique number representing a character that’s acknowledged as the global identifier for that character in the world of information technology.

The Unicode number provides a consistent and compatible representation of each character in many technological systems.

For example, the Unicode number 65 equals A the uppercase letter, while Unicode number 97 equals a the lowercase letter.

For the full list of Unicode number, refer to Wikipedia here

You can use the method by calling it directly from the String object instead of the object’s instance.

The fromCharCode() syntax is as follows:

String.fromCharCode(unicodeNum, unicodeNum, ...);

You are free to pass one or more Unicode numbers as you need. The method will return an empty string "" if you don’t pass any valid Unicode numbers.

Here’s an example of the method in action:

String.fromCharCode(65); // "A"
String.fromCharCode(65, 66, 67); // "ABC"
String.fromCharCode(72, 69, 89); // "HEY"
String.fromCharCode(); // ""

The return value of the method will be a string that you can use further in your JavaScript application.

Take your skills to the next level ⚡️

I'm sending out an occasional email with the latest tutorials on programming, web development, and statistics. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.