String.fromCharCode(72) gives H. How开发者_高级运维 to get number 72 from char H?
'H'.charCodeAt(0)
Use charCodeAt:
var str = 'H';
var charcode = str.charCodeAt(0);
@Silvio's answer is only true for code points up to 0xFFFF (which in the end is the maximum that String.fromCharCode can output). You can't always assume the length of a character is one:
'
精彩评论