METHOD:  String::charAt

object.charAt(index)

This method returns a character from a string by referring to it's 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.

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

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

Copyright 2000 by Infinite Software Solutions, Inc.
Trademark Information