JavaScript » String » charAt

Syntax:
object.charAt(index)

This method returns a character from a string by referring to its index within that string.

The characters in a string are indexed from left to right with the first character indexed as 0 and the last as String.length - 1.

Examples

Code:
myString = new String("charAt method demonstration.")
document.write (myString.charAt(26))
document.write (myString.charAt(8))
document.write (myString.charAt(2))
document.write (myString.charAt(5))
Output:
neat
Explanation:

This code reads the characters from the string at the specified indicies and writes them to the document.