![]() |
VOOZH | about |
The charAt() method in JavaScript is used to get a character from a string at a specific position. It helps you access individual characters easily using an index value.
Syntax:
character = str.charAt(index);The charAt() method accepts a single parameter called index. This index determines which character from the string will be returned.
The charAt() method returns a value based on the index you provide. It gives you the character found at that specific position in the string.
[Example 1]: Retrieving Characters at Specific Indices using JavaScript String charAt() Method.
The charAt() method is used to retrieve a character from a string at a specific index.
[Example 2]: Retrieving Character at Out-of-Bounds Index with JavaScript String charAt() Method
The charAt() method returns an empty string when the given index is outside the string length.