JavaScript charCodeAt方法示例
<html>
<head>
<title>JavaScript String charCodeAt() Method</title>
</head>
<body>
<script type="text/javascript">
var st = new String("God is girl");
document.write("st.charCodeAt(0) is:" + st.charCodeAt(0));
document.write("<br />st.charCodeAt(1) is:" + st.charCodeAt(1));
document.write("<br />st.charCodeAt(2) is:" + st.charCodeAt(2));
document.write("<br />st.charCodeAt(3) is:" + st.charCodeAt(3));
document.write("<br />st.charCodeAt(4) is:" + st.charCodeAt(4));
document.write("<br />st.charCodeAt(5) is:" + st.charCodeAt(5));
</script>
</body>
</html>
JavaScript 字符串charCodeAt方法
JS中字符串的charCodeAt()方法用于返回特定索引处的字符的Unicode值。
此方法的语法如下:
string.charCodeAt(index);
在上面的CharCodeat()方法的语法中,参数index是整数值,指示在字符串中我们将要获得Unicode值的字符的索引。
日期:2020-04-18 01:09:19 来源:oir作者:oir
