charCodeAt()
String
instance method getterS2C Home
« Globals « String « charCodeAt()
Description
Returns a numeric Unicode value of the character at the specified index.
Syntax
Signature | Description |
---|---|
aString.charCodeAt(index) | Returns a numeric Unicode value of the character at the specified index. |
Parameters
Parameter | Description |
---|---|
index | An integer between 0 and the length of the string -1, up to 65,535.
|
Examples
The code below creates a string of the alphabet and returns a numeric Unicode value.
// Create alphabet string varible.
var theAlphabet = 'abcdefghijklmnopqrstuvwxyz';
// Return numeric Unicode value of the character at index 0.
alert(theAlphabet.charCodeAt(0));
Related Tutorials
JavaScript Basic Tutorials - Lesson 8 - Strings