Home >Web Front-end >Front-end Q&A >What character function does javascript use to convert ascii to characters
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)".
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'
Output result:
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!