1.charAt方法,用于獲取相應索引位置的字符串
參數:索引(index)
返回值:一個字符
var str = "fuck";
getchar = str.charAt(1);
console.log(getchar);
輸出結果:u
2.charCodeAt方法,用于獲取相應索引位置的字符的unicode編碼
參數:索引(index)
返回值:具體的Unicode字符編碼
var str2 = "helloworld";
var strCode = str2.charCodeAt(2);
console.log(strCode);
輸出結果:101