Hacker News new | ask | show | jobs
by jakelazaroff 1886 days ago
You can’t have a negative array index. Passing a negative number will just make this function count backwards instead of forwards.

[1, 2, 3, 4].at(0) === 1

[1, 2, 3, 4].at(1) === 2

[1, 2, 3, 4].at(-1) === 4

findIndex’s behavior is unchanged.