js字符与ASCII码互转的方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiaobing_hope/article/details/78645273

大写字母A-Z对应的ASCII码值是65-90
小写字母a-z对应的ASCII码值是97-122

将字母转为ascii嘛的方法:

var str = "A";
str.charCodeAt();  // 65

var str1 = 'a';
str1.charCodeAt();  // 97

将ascii码转为对应字母的方法:

var num = 97;
String.fromCharCode(num);  // 'a'

var num1 = 100;
String.fromCharCode(num1);  // 'd'

猜你喜欢

转载自blog.csdn.net/xiaobing_hope/article/details/78645273