最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - String.charCodeAt undefined? - Stack Overflow

programmeradmin1浏览0评论

I get this error in the javascript debug panel when trying to call String.charCodeAt('9') in Safari 3.

TypeError: Result of expression 'String.charCodeAt' [undefined] is not a function.

When I try to do stringInstance.charCodeAt('9') instead, I get NaN. Am I doing something wrong? I'd just like to get the char code for some characters to match against keypresses. String.charCodeAt('9') returns 57 (as expected) on Firefox.

I get this error in the javascript debug panel when trying to call String.charCodeAt('9') in Safari 3.

TypeError: Result of expression 'String.charCodeAt' [undefined] is not a function.

When I try to do stringInstance.charCodeAt('9') instead, I get NaN. Am I doing something wrong? I'd just like to get the char code for some characters to match against keypresses. String.charCodeAt('9') returns 57 (as expected) on Firefox.

Share Improve this question asked Oct 9, 2009 at 6:32 readonlyreadonly 356k109 gold badges206 silver badges206 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

I think the proper way is:

"9".charCodeAt(0)

or stringInstace.charCodeAt(charIndex) where charIndex is an integer

发布评论

评论列表(0)

  1. 暂无评论