Array/String .at() Method
JS · Modern Featuressyntax
arr.at(index)
str.at(index)example
const stack = ["first", "second", "third", "last"];
console.log(stack.at(0)); // "first"
console.log(stack.at(-1)); // "last"
console.log(stack.at(-2)); // "third"
console.log("hello".at(-1)); // "o"Note Works on Arrays, Strings, and TypedArrays. The main advantage over bracket notation is support for negative indices.