Home > Web Front-end > Front-end Q&A > What character function does javascript use to convert ascii to characters

What character function does javascript use to convert ascii to characters

青灯夜游
Release: 2021-10-13 16:31:31
Original
5691 people have browsed it

In javascript, you can use the fromCharCode() function of the String object to convert the ascii code into the corresponding character. This function can accept a specified Unicode value and then return a string; the specific syntax is "String.fromCharCode (ascii code)".

What character function does javascript use to convert ascii to characters

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

In javascript, you can use the fromCharCode() function of the String object to convert the ascii code into the corresponding character.

Example:

var num = 97;
console.log(String.fromCharCode(num));  // 'a'

var num1 = 100;
console.log(String.fromCharCode(num1));  // 'd'
Copy after login

Output result:

What character function does javascript use to convert ascii to characters

Description:

fromCharCode() accepts one The specified Unicode value, then returns a string.

Note: This method is a static method of String. Each character in the string is specified by a separate Unicode numeric encoding.

Syntax: String.fromCharCode(n1, n2, ..., nX)

Return value: Returns the character representing Unicode encoding.

[Recommended learning: javascript advanced tutorial]

The above is the detailed content of What character function does javascript use to convert ascii to characters. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template