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); }
Name | Type(s) | Description |
---|---|---|
i | number | The index of the character whose character code you want. |
returns | number | The character code. |
Examples
Lazy("abc").charCodeAt(0) // => 97 Lazy("abc").charCodeAt(-1) // => NaN Lazy("abc").charCodeAt(10) // => NaN