charAt (JavaScript)
Gets the character at a specified index.
Parameters |
Description |
pos |
The index (position) of the character, where
0 is the index of the first character. The last index is the length
of the string minus 1. |
Returns |
Description |
string |
The character at the specified index, or an
empty string if the index is out of range. |
Examples
This example returns
First
= P Last = o
.
var cities = new String("Paris Moscow Tokyo");
"First = " + cities.charAt(0) +
"\nLast = " + cities.charAt(cities.length() - 1)
Have feedback?
Google Analytics is used to store comments and ratings. To provide a comment or rating for a topic, click Accept All Cookies or Allow All in Cookie Preferences in the footer of this page.