The charAt(..) function is used to return us the character of a String if we supply it with index value.
Say, if we want to know which character is present at 2nd index of the String "World". Assuming the count starts from 0.
<html> <body> <script> var firstString = "World" var pos = firstString.charAt(2) document.write("The character is : ", pos) </script> </body> </html>
So, in the above code, we have a String World initialised to a variable x.
Then we have used the charAt() Function to get the letter at index 2.
var pos = firstString.charAt(2)
And as we can see, the letter at index 2 is r.
So, r is taken and put into the variable pos.