JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

String.charAt() Method

Name

String.charAt() Method---get the nth character from a string

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

string.charAt(n)

Arguments

n

The index of the character that should be returned from string.

Returns

The nth character of string.

Description

String.charAt() returns the nth character of the string string. The first character of the string is numbered 0. If n is not between 0 and string.length - 1, then this method returns an empty string. Note that JavaScript does not have a character datatype that is distinct from the string type, so the returned character is a string of length 1.

See Also

"String", "String.indexOf()", "String.lastIndexOf()"


Previous Home Next
String.bold() Book Index String.fixed()

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell