Skip to content

From char code new entry #7046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
Title: 'fromCharCode()'
Description: 'Returns a string created from the specified sequence of UTF-16 code units.'
Subjects:
- 'Computer Science'
- 'Web Development'
Tags:
- 'Characters'
- 'JavaScript'
- 'Methods'
- 'Strings'
CatalogContent:
- 'introduction-to-javascript'
- 'paths/front-end-engineer-career-path'
---

In JavaScript, the **`fromCharCode()`** method creates a string by converting one or more UTF-16 code units (numeric values) into their corresponding characters. This method is often applied in scenarios involving character encoding, dynamic character generation, or simple encryption tasks. It is particularly useful for converting ASCII or Unicode values into readable text.

## Syntax

```pseudo
String.fromCharCode(num1, num2, ..., numN)
```

**Parameters:**

- `num1, num2, ..., numN` (Number): One or more integer values representing UTF-16 code units. Each number should be between 0 and 65535.

**Return value:**

Returns a string composed of characters corresponding to the provided UTF-16 code units.

## Example

The following code converts a sequence of UTF-16 code units into the string "Liany❤️" and logs it to the console:

```js
const number = String.fromCharCode(76, 105, 97, 110, 121, 10084, 65039);
console.log(number);
```

The output of this code is:

```shell
Liany❤️
```

## Codebyte Example

Run the following code to understand the working of the `fromCharCode()` method:

```codebyte/javascript
const secret = String.fromCharCode(
76, 111, 110, 103, 32, 108, 105, 118, 101, 32, 116, 104, 101, 32, 107, 105, 116, 116, 105, 101, 115
);
console.log(secret);
```