JScript 8.0 中文手册| 首页 | asp之家
charCodeAt 方法

返回一个整数,该整数表示 String 对象中指定位置处的字符的 Unicode 编码。

function charCodeAt(index : Number) : String
参数
index

必选。所需字符的从零开始的索引。有效值为 0 到字符串长度减 1 的数字。

备注

一个字符串中的第一个字符位于索引位置 0,第二个字符位于索引位置 1,依此类推。

如果指定 index 没有字符,将返回 NaN

示例

下面的示例阐释了 charCodeAt 方法的用法。

function charCodeAtTest(n){
  var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //Initialize variable.
  var n;                                  //Declare variable.
  n = str.charCodeAt(n - 1);              //Get the Unicode value of the
                                          // character at position n.
  return(n);                              //Return the value.
}
要求

版本 5.5

应用于:

请参见

参考

fromCharCode 方法