at() method returns the character at a specified index (position) in a string.
syntax ↴
at(index) ↴
index The index (position) of the string character to be returned.
The first position is 0, the second is 1, ...
A negative number counts back from the end of the string.
at() method returns a new string consisting of the single UTF-16 code unit located at the given index (position) in the string.
at() method returns undefined if the given index cannot be found.
const myString = 'Hello World';
myString.at(0); returns 'H'
myString[0]; returns 'H' (but you cannot use a negative index).
at() method is similar to charAt() method except ↴
at() method allows a negative index and returns undefined if the given index cannot be found.
charAt() method does not allow a negative index and returns an empty string "" if the given index cannot be found.
myString.at(index)