Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String.charCodeAt undefined?

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.

like image 330
readonly Avatar asked Oct 09 '09 06:10

readonly


1 Answers

I think the proper way is:

"9".charCodeAt(0)

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

like image 120
jerjer Avatar answered Oct 24 '22 09:10

jerjer