at
Retrieves the element at the specified index
in the arr
array. Supports negative indices, which count from the end of the array.
arr
(T[]
): The input array.index
(number
): The index of the element to retrieve. Can be negative.T | undefined
): The element at the specified index, or undefined
if the index is out of bounds or the array is empty.