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