发布于:2020-07-18 11:11:11
在 JavaScript 中,为了获取一个字符的ASCII码,需要使用 charCodeAt() 方法。
举例:
var s = 'A';
s = s.charCodeAt(0);
console.log(s);
//输出: 65
如果想从ASCII码得到一个字符,需要使用 fromCharCode() 方法。
举例:
var s = String.fromCharCode(65);
console.log(s);
//输出: 'A'
阅读 100000+
100000+