It seems like you're pretty passionate about having a last() but I don't really see the issue. at(-1) uses the same number of characters as last() so it's no more verbose, plus it has the added benefit of providing a uniform way of accessing array items from the end of the array regardless of how many positions back from the end you need it.
A multi-purpose solution seems preferable to a method that can only do one thing, no?
That aside, if people start using .at(positiveIndex), that's on them. We already have people swearing off for loops and thinking reduce is the catch all solution for everything, and I think those issues are far more detrimental to this.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It seems like you're pretty passionate about having a
last()
but I don't really see the issue.at(-1)
uses the same number of characters aslast()
so it's no more verbose, plus it has the added benefit of providing a uniform way of accessing array items from the end of the array regardless of how many positions back from the end you need it.A multi-purpose solution seems preferable to a method that can only do one thing, no?
That aside, if people start using
.at(positiveIndex)
, that's on them. We already have people swearing offfor
loops and thinkingreduce
is the catch all solution for everything, and I think those issues are far more detrimental to this.