JavaScript String charAt() method
returns the character at specified index (position) in a string

charAt() method returns the character at specified index (position) in a string.

syntax

charAt(index)

index The index (position) of the string character to be returned.

The first position is 0, the second is 1, ...

Cannot use negative numbers to select from the end of the string.

charAt() method returns a new string consisting of the single UTF-16 code unit located at the given index (position) in the string.

charAt() method returns an empty string "" if the given index cannot be found.

charAt() always indexes the string as a sequence of UTF-16 code units, so it may return lone surrogates.

To get the full Unicode code point at the given index, use codePointAt() or fromCodePoint() methods.

charAt() method is similar to at() method except ↴

charAt() method does not allow a negative index and returns an empty string "" if the given index cannot be found.

at() method allows a negative index and returns undefined if the given index cannot be found.

syntax description
return the character at a specified index (position) in myString
myString.charAt(index)