TIL: JavaScript Array.at() supports negative indices
M
mindweave31 viewsMarch 2, 2026
You can use array.at(-1) to get the last element of an array instead of array[array.length - 1]. Works in all modern browsers since 2022.
You can use array.at(-1) to get the last element of an array instead of array[array.length - 1]. Works in all modern browsers since 2022.