当前位置: 首页 > 文档资料 > Lazy.js 英文文档 >

charCodeAt

优质
小牛编辑
132浏览
2023-12-01

Returns the character code at the given index of this sequence, or NaN if the index lies outside the bounds of the sequence.

Signature

StringLikeSequence.charCodeAt = function(i) { /*...*/ }
StringLikeSequence.charCodeAt = function charCodeAt(i) {
  var char = this.charAt(i);
  if (!char) { return NaN; }

  return char.charCodeAt(0);
}
NameType(s)Description
inumber

The index of the character whose character code you want.

returnsnumber

The character code.

Examples

Lazy("abc").charCodeAt(0)  // => 97
Lazy("abc").charCodeAt(-1) // => NaN
Lazy("abc").charCodeAt(10) // => NaN