The charAt(index) method is a built-in JavaScript string method that retrieves the character at a specified index within a string. Below is a detailed look at its usage, parameters, and practical examples.
Index Out of Range: If an index beyond the string length is specified, charAt returns an empty string instead of throwing an error.
Difference from Square Brackets ( []): You can also access characters using string[index], but this approach does not handle out-of-range indexes safely (it returns undefined instead).
The charAt(index) method is a straightforward and versatile tool for character extraction in JavaScript. Its ability to return an empty string for out-of-range indexes makes it a safe choice for character processing, string parsing, looping, and handling special characters.