字符方法
1. charAt() 查找對應位置的字符
2. charCodeAt() 查找對應位置字符的字符編碼
傳入一個下標索引值作為引數,
// charAt() charCodeAt()
var str = "Hello world!";
console.log(str.charAt(1)); // 下標為1位置的字符是什么 e
console.log(str.charCodeAt(1)); // e的對應字符編碼是什么 101
console.log('a'.charCodeAt()); // 97
console.log("工藤新一".charCodeAt(1)); // 藤字的字符編碼

轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/144630.html
標籤:JavaScript
上一篇:js獲取檔案后綴名方法
