Next: concat
Up: Methods
Previous: charAt
Contents
charCodeAt
Description
Returns the ascii code of the specified character.
Syntax
- StringObj.charCodeAt(index)
- "String Literal".charCodeAt(index)
Parameters
- index
- An integer that specifies the position of a character in the string. The first character is indicated by 0, and the last character is indicated by stringObj.length-1.
returns
Returns an integer represents the character specified by index. If index is not a number from 0 to stringObj.length - 1, returns NAN.
Example
s = new String("Chris");
i = s.charCodeAt(0);
// i = 67
Copyright ©2000-2010 Shanghai TopCMM Software Technologies. All Rights Reserved.