返回一个整数,该整数表示 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. }要求