charCodeAt 方法
傳回的整數代表在 String 物件所指定位置之字元的 Unicode 編碼。
function charCodeAt(index : Number) : String
引數
- Index - 索引
必要項。 必要字元以零起始的索引。 有效值介於 0 到字串長度減 1 之間。
備註
字串中第一個字元的索引是 0,第二個字元的索引是 1,依此類推。
如果指定的 index 位置上沒有任何字元,即傳回 NaN。
範例
下列範例說明如何使用 charCodeAt 方法。
function charCodeAtTest(n)
{
var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// Get the Unicode value of the character that is at position n.
var n = str.charCodeAt(n - 1);
return(n);
}