proposal-array-last
proposal-array-last copied to clipboard
lastElement as an alias of lastItem
What about using Array.prototype.lastElement() as an alias of Array.prototype.lastItem()?
The reason I suggest this is because usually when referring to the content of an Array, don't most coders say element instead of item? (If they don't, forget I mentioned this 😝)
I don't think adding aliases is a good idea; we should pick one term.
That also has less value by performance/compactness compared to just a[a.length-1].
@dy not having to mention a twice is all the value this proposal needs imo (just not for more than one way to spell it)
I believe the better solution is a[^1] 😆
Maybe we should consider rework this proposal?
I'm not convinced syntax is a better solution, or even a sensible one here.
They are referred to as elements on MDN, but I'd defer to @ljharb & @hax to what The Standard tends to use out of the two.
However, lastElement actually might be better from the autocomplete perspective: right now both properties match lastI, whereas by using lastElement it becomes just last.
It's a small point given it's one letter, but I feel like since item & element are (relatively, for the sake of this issue at least) synonymous, that could be a nice bikeshed-breaker?