revision:
The String.fromCharCode() method converts Unicode values to characters. The String.fromCharCode() is a static method of the String object. The syntax is always String.fromCharCode(). You cannot use myString.fromCharCode().
String.fromCharCode(n1, n2, ..., nX)
Parameters:
n1, n2, nX : required. One or more Unicode values to be converted.
<p>Convert 65 to a string:</p> <p id="demo"></p> <script> let text = String.fromCharCode(65); document.getElementById("demo").innerHTML = text; </script>
console.log(String.fromCharCode(189, 43, 190, 61)); // Expected output: "½+¾="
String.fromCharCode(65, 66, 67); // returns "ABC" String.fromCharCode(0x2014); // returns "—" String.fromCharCode(0x12014); // also returns "—"; the digit 1 is truncated and ignored String.fromCharCode(8212); // also returns "—"; 8212 is the decimal form of 0x2014
example: chek if a string ends with "...".
Convert 65 to a string:
Convert 72, 69, 76, 76, 79 to a string:
<div> <p>Convert 65 to a string:</p> <p id="from-1"></p> <p id="from-2"></p> <p>Convert 72, 69, 76, 76, 79 to a string:</p> <p id="from-3"></p> </div> <script> let text = String.fromCharCode(65); document.getElementById("from-1").innerHTML = " String.fromCharCode(65)"; document.getElementById("from-2").innerHTML = "string is : " + text; let text1 = String.fromCharCode(72, 69, 76, 76, 79); document.getElementById("from-3").innerHTML = text1; </script>