fromCharCode()
takes one or more character codes and
convert them into a string.
This is a static method of the String object.
fromCharCode() |
Yes | Yes | Yes | Yes | Yes |
String.fromCharCode(n1, n2, ..., nX);
Parameter | Description |
---|---|
n1, n2, ..., nX | Required. One or more Unicode values to convert |
A string converted from unicode number(s).
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!-- w w w . j ava 2 s .co m-->
var res = String.fromCharCode(66);
document.getElementById("demo").innerHTML = res;
}
</script>
</body>
</html>
The code above is rendered as follows:
console.log(String.fromCharCode(104, 101, 108, 108, 111));
The code above generates the following result.