str.charAT() Returns character at given index of string.
character = str.charAt(index)
The only argument to this function is the index in the string from where the single character is to be extracted. The range of this index is between 0 and length – 1, including the limits. If no index is specified then the first character of the string is returned as 0 is the default index used for this function.
This function returns a single character located at the index specified as the argument to the function. If the index is out of range, then this function returns an empty string.
Examples for the above function are provided below:
In this example the function charAt() finds the character at index 9 and returns it.
In this example the function charAt() finds the character at index 50. Since the index is out of bounds for the given string therefore the function returns “” an empty string.
Codes for the above function are provided below:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai