proposal-array-last icon indicating copy to clipboard operation
proposal-array-last copied to clipboard

lastElement as an alias of lastItem

Open futagoza opened this issue 5 years ago • 6 comments

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 😝)

futagoza avatar Jul 26 '18 21:07 futagoza

I don't think adding aliases is a good idea; we should pick one term.

ljharb avatar Jul 26 '18 22:07 ljharb

That also has less value by performance/compactness compared to just a[a.length-1].

dy avatar May 04 '20 20:05 dy

@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)

ljharb avatar May 04 '20 20:05 ljharb

I believe the better solution is a[^1] 😆

Maybe we should consider rework this proposal?

hax avatar May 11 '20 18:05 hax

I'm not convinced syntax is a better solution, or even a sensible one here.

ljharb avatar May 11 '20 21:05 ljharb

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?

G-Rath avatar May 11 '20 21:05 G-Rath