String.fromCharCode(72) gives H. How to get number 72 from char H?
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.
The fromCharCode() method accepts a sequence of Unicode values. These Unicode values are UTF-16 values (16-bit integers between 0 and 65535) that are converted to characters and concatenated together in a string. This resulting string is then returned by the fromCharCode() method.
The charCodeAt() method returns an integer between 0 and 65535 representing the UTF-16 code unit at the given index.
Definition and Usage Note: The charCode property is deprecated. Use the key property instead. The charCode property returns the Unicode character code of the key that triggered the onkeypress event. The Unicode character code is the number of a character (e.g. the number "97" represents the letter "a").
'H'.charCodeAt(0)
Use charCodeAt:
var str = 'H'; var charcode = str.charCodeAt(0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With