Javascript : charAt()

For JavaScript strings, there is a method called charAt(). It is employed to extract the character from a string at a certain index. The charAt() method takes an index as an input and returns the character that is at that index. An empty string is returned if the index is out of range (less than 0 or larger than or equal to the length of the string).

Functionstring.charAt(index)
Explanationstring: The string that the character should be retrieved from.
index: The character to be retrieved zero-based index.

Examples

let str = "Hello, World!";
console.log(str.charAt(0)); // Output: "H"
console.log(str.charAt(7)); // Output: "W"