String Function - charAt()
: StringMethod or Function
: This method takes an integer value as argument and returns the character at that position in the string. The positioning of the string starts from zero to n. i.e. The first character of the string is assumed to be at position zero (0), next at 1 and so on.
var ss = "a string test ";
var result = ss.charAt(3);
In the above example,
- the string is stored in a variable ss.
- then we called the function or method charAt(3), to get the character at position 3 in the string.
- the positioning is as 0-a, 1- , 2-r, 3-t, ....
- character at position 3 is 't' and so 't' is returned as result.
- the result is of variable type, string.