
charCodeAt()方法返回一个数字,表示给定索引处字符的Unicode值。Unicode代码点范围从0到1,114,111。前128个Unicode代码点与ASCII字符编码直接匹配。
charCodeAt(index)支持以下参数:
index – 一个介于0和字符串长度减1之间的整数;如果未指定,默认为0。
示例
您可以尝试运行以下代码来返回表示字符的Unicode值的数字:
JavaScript String charCodeAt() Method var str = new String( "This is string" ); document.write("str.charCodeAt(0) is:" + str.charCodeAt(0)); document.write("
str.charCodeAt(1) is:" + str.charCodeAt(1)); document.write("
str.charCodeAt(2) is:" + str.charCodeAt(2)); document.write("
str.charCodeAt(3) is:" + str.charCodeAt(3)); document.write("
str.charCodeAt(4) is:" + str.charCodeAt(4)); document.write("
str.charCodeAt(5) is:" + str.charCodeAt(5));
以上就是如何返回一个表示字符的Unicode值的数字?的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1551967.html
微信扫一扫
支付宝扫一扫