JS String fromCharCode/charCodeAt

1. String.fromCharCode()

   静态 String.fromCharCode() 方法返回由指定的UTF-16代码单元序列创建的字符串。

 newStr += String.fromCharCode(((str[i].charCodeAt(0) - 18) % 26) + 97)  

 

2. charCodeAt ()

 返回值是一表示给定索引处(String中index索引处)字符的 UTF-16 代码单元值的数字;如果索引超出范围,

    则返回 NaN

    注意,charCodeAt 总是返回一个小于 65,536 的值。

"ABC".charCodeAt(0) // returns 65:"A"

  

posted @ 2019-06-27 13:52  Loki-Liu  阅读(563)  评论(0编辑  收藏  举报