String.charCodeAt undefined?

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

TypeError: The result of the 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 would just like the char code for some characters to match the keys. String.charCodeAt ('9') returns 57 (as expected) in Firefox.

+5
source share
1 answer

I think the correct way is:

"9" .charCodeAt (0)

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

+3
source

All Articles