String.charCodeAt()

JavaScript1.0+, JScript1.0+, ECMAScript1.0+ NES2+, Nav2+, IE3+, Opera3+ Syntax

							string.charCodeAt(num)

Description

The charCodeAt() method of an instance of the String object returns the ISO-Latin-1 number of the character located at the indexed, num, position passed. This indexing is done from left to right starting with the 0 (zero) position. If the num passed is not a valid index in the string, –1 is returned.

Example

Listing 6.234 creates an instance of a String object. When the page is loaded, the user is then prompted for an index number. After entering the index number and OK, the ISO-Latin-1 number of the character at that indexed location is written to the document. Notice that there is also a check to see ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.